TUtils-cli 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- tutils_cli-0.1.0/.gitignore +57 -0
- tutils_cli-0.1.0/LICENSE +21 -0
- tutils_cli-0.1.0/PKG-INFO +50 -0
- tutils_cli-0.1.0/README.md +29 -0
- tutils_cli-0.1.0/devbuild.sh +9 -0
- tutils_cli-0.1.0/docs/architecture.md +2 -0
- tutils_cli-0.1.0/docs/development/config.md +30 -0
- tutils_cli-0.1.0/docs/development/index.md +47 -0
- tutils_cli-0.1.0/docs/development/repository.md +52 -0
- tutils_cli-0.1.0/docs/index.md +98 -0
- tutils_cli-0.1.0/docs/installation.md +6 -0
- tutils_cli-0.1.0/docs/quickstart.md +16 -0
- tutils_cli-0.1.0/examples/README.md +3 -0
- tutils_cli-0.1.0/examples/Scripts/default/Z2V0RmlsZUNvdW50/getfilecount.py +54 -0
- tutils_cli-0.1.0/examples/Scripts/default/Z2V0RmlsZUNvdW50/index.yaml +9 -0
- tutils_cli-0.1.0/examples/Scripts/default/index.yaml +3 -0
- tutils_cli-0.1.0/examples/config.yaml +9 -0
- tutils_cli-0.1.0/pyproject.toml +38 -0
- tutils_cli-0.1.0/test/test_cli.py +21 -0
- tutils_cli-0.1.0/tutils/__init__.py +22 -0
- tutils_cli-0.1.0/tutils/__main__.py +6 -0
- tutils_cli-0.1.0/tutils/cli.py +278 -0
- tutils_cli-0.1.0/tutils/config.py +281 -0
- tutils_cli-0.1.0/tutils/const.py +29 -0
- tutils_cli-0.1.0/tutils/env.py +10 -0
- tutils_cli-0.1.0/tutils/model.py +115 -0
- tutils_cli-0.1.0/tutils/repository/__init__.py +0 -0
- tutils_cli-0.1.0/tutils/repository/model.py +29 -0
- tutils_cli-0.1.0/tutils/repository/repositoryindexfile.py +59 -0
- tutils_cli-0.1.0/tutils/repository/scriptindexfile.py +33 -0
- tutils_cli-0.1.0/tutils/runner.py +145 -0
- tutils_cli-0.1.0/tutils/scripts.py +133 -0
- tutils_cli-0.1.0/tutils/utils.py +41 -0
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
# Python
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[cod]
|
|
4
|
+
*$py.class
|
|
5
|
+
*.so
|
|
6
|
+
.Python
|
|
7
|
+
build/
|
|
8
|
+
develop-eggs/
|
|
9
|
+
dist/
|
|
10
|
+
downloads/
|
|
11
|
+
eggs/
|
|
12
|
+
.eggs/
|
|
13
|
+
lib/
|
|
14
|
+
lib64/
|
|
15
|
+
parts/
|
|
16
|
+
sdist/
|
|
17
|
+
var/
|
|
18
|
+
wheels/
|
|
19
|
+
pip-wheel-metadata/
|
|
20
|
+
share/python-wheels/
|
|
21
|
+
*.egg-info/
|
|
22
|
+
.installed.cfg
|
|
23
|
+
*.egg
|
|
24
|
+
MANIFEST
|
|
25
|
+
|
|
26
|
+
# Testing
|
|
27
|
+
.pytest_cache/
|
|
28
|
+
.coverage
|
|
29
|
+
htmlcov/
|
|
30
|
+
.tox/
|
|
31
|
+
.hypothesis/
|
|
32
|
+
|
|
33
|
+
# Virtual environments
|
|
34
|
+
venv/
|
|
35
|
+
env/
|
|
36
|
+
ENV/
|
|
37
|
+
env.bak/
|
|
38
|
+
venv.bak/
|
|
39
|
+
|
|
40
|
+
# IDE
|
|
41
|
+
.vscode/
|
|
42
|
+
.idea/
|
|
43
|
+
*.swp
|
|
44
|
+
*.swo
|
|
45
|
+
*~
|
|
46
|
+
.DS_Store
|
|
47
|
+
*.sublime-project
|
|
48
|
+
*.sublime-workspace
|
|
49
|
+
|
|
50
|
+
# OS
|
|
51
|
+
Thumbs.db
|
|
52
|
+
.DS_Store
|
|
53
|
+
|
|
54
|
+
# Project specific
|
|
55
|
+
*.log
|
|
56
|
+
.env
|
|
57
|
+
.env.local
|
tutils_cli-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Jared3Dev
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: TUtils-cli
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: TUtils command-line utility toolkit
|
|
5
|
+
Project-URL: Homepage, https://github.com/ruxia-TJY/TUtils
|
|
6
|
+
Project-URL: Documentation, https://github.com/ruxia-TJY/TUtils
|
|
7
|
+
Project-URL: Repository, https://github.com/ruxia-TJY/TUtils.git
|
|
8
|
+
Project-URL: Bug Tracker, https://github.com/ruxia-TJY/TUtils/issues
|
|
9
|
+
Author-email: Jared3Dev <ruxia.tjy@qq.com>
|
|
10
|
+
License-Expression: MIT
|
|
11
|
+
License-File: LICENSE
|
|
12
|
+
Keywords: TUtils,cli,command-line
|
|
13
|
+
Classifier: Environment :: Console
|
|
14
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
15
|
+
Requires-Python: >=3.8
|
|
16
|
+
Requires-Dist: pydantic>=1.10.0
|
|
17
|
+
Requires-Dist: pyyaml>=6.0
|
|
18
|
+
Requires-Dist: rich
|
|
19
|
+
Requires-Dist: typer>=0.23.1
|
|
20
|
+
Description-Content-Type: text/markdown
|
|
21
|
+
|
|
22
|
+
# TUtils
|
|
23
|
+
|
|
24
|
+
Most of my work involves using the command line, and sometimes it's simply faster than launching new software. I love Python because countless talented developers have created powerful packages that let me accomplish all sorts of tasks through it. I want to build a command-line tool that lets me achieve what I need without worrying about the underlying code. And I'm still developing it.
|
|
25
|
+
|
|
26
|
+
See [doc](./docs/index.md) for more details.
|
|
27
|
+
|
|
28
|
+
## How to Use
|
|
29
|
+
|
|
30
|
+
You can install TUtils using pip:
|
|
31
|
+
|
|
32
|
+
```
|
|
33
|
+
pip install tutils # No,Not yet submitted to PyPI,Please install it from source code.
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
After installation, you can use the `tutils` command followed by the desired subcommand to perform various tasks. For example:
|
|
37
|
+
|
|
38
|
+
```
|
|
39
|
+
tutils subcommand [options]
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
For detailed usage instructions and available subcommands, please refer to the documentation or run:
|
|
43
|
+
|
|
44
|
+
```
|
|
45
|
+
tutils --help
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
## LICENSE
|
|
49
|
+
|
|
50
|
+
MIT,Thanks!
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# TUtils
|
|
2
|
+
|
|
3
|
+
Most of my work involves using the command line, and sometimes it's simply faster than launching new software. I love Python because countless talented developers have created powerful packages that let me accomplish all sorts of tasks through it. I want to build a command-line tool that lets me achieve what I need without worrying about the underlying code. And I'm still developing it.
|
|
4
|
+
|
|
5
|
+
See [doc](./docs/index.md) for more details.
|
|
6
|
+
|
|
7
|
+
## How to Use
|
|
8
|
+
|
|
9
|
+
You can install TUtils using pip:
|
|
10
|
+
|
|
11
|
+
```
|
|
12
|
+
pip install tutils # No,Not yet submitted to PyPI,Please install it from source code.
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
After installation, you can use the `tutils` command followed by the desired subcommand to perform various tasks. For example:
|
|
16
|
+
|
|
17
|
+
```
|
|
18
|
+
tutils subcommand [options]
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
For detailed usage instructions and available subcommands, please refer to the documentation or run:
|
|
22
|
+
|
|
23
|
+
```
|
|
24
|
+
tutils --help
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
## LICENSE
|
|
28
|
+
|
|
29
|
+
MIT,Thanks!
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
# Config
|
|
2
|
+
|
|
3
|
+
## Overview
|
|
4
|
+
|
|
5
|
+
config file will be created in `~/.tutils/config.yaml` when first run, and you can edit it to change the configuration of TUtils.
|
|
6
|
+
|
|
7
|
+
The program reads the configuration file each time it runs.
|
|
8
|
+
|
|
9
|
+
## Content
|
|
10
|
+
|
|
11
|
+
Configuration files are saved in YAML format. Example content:
|
|
12
|
+
|
|
13
|
+
```yaml
|
|
14
|
+
app_name: TUtils
|
|
15
|
+
app_version: 0.1.0
|
|
16
|
+
debug: false
|
|
17
|
+
log_level: INFO
|
|
18
|
+
use_color: true
|
|
19
|
+
verbose: false
|
|
20
|
+
repository:
|
|
21
|
+
- path: /home/jared/.tutils/Scripts
|
|
22
|
+
type: local
|
|
23
|
+
link: https://github.com/tutils/tutils/index.yaml
|
|
24
|
+
custom: {}
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
+ `repository`: the repository list, each repository is a dict with `path` `type` and `link`
|
|
28
|
+
+ `path`: the local path of repository
|
|
29
|
+
+ `type`: the type of repository, now support `local` and `web`, if `web`,run command-line `repository update` while download to local `path`
|
|
30
|
+
+ `link`: the link of repository, if type is `web`, it must be set
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
# Development
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
## To TestPyPI
|
|
9
|
+
|
|
10
|
+
Changed pyproject.toml
|
|
11
|
+
```toml
|
|
12
|
+
[project]
|
|
13
|
+
name="TUtils-cli"
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
# Add
|
|
17
|
+
[tool.hatch.build.targets.wheel]
|
|
18
|
+
packages = ["tutils"]
|
|
19
|
+
```
|
|
20
|
+
build
|
|
21
|
+
```bash
|
|
22
|
+
python -m build
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
twine upload --repository testpypi dist/*
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
## To PyPI
|
|
30
|
+
|
|
31
|
+
Changed to back
|
|
32
|
+
```toml
|
|
33
|
+
name="TUtils"
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
# Delete
|
|
37
|
+
[tool.hatch.build.targets.wheel]
|
|
38
|
+
packages = ["tutils"]
|
|
39
|
+
```
|
|
40
|
+
Rebuild
|
|
41
|
+
```bash
|
|
42
|
+
python -m build
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
```bash
|
|
46
|
+
twine upload dist/*
|
|
47
|
+
```
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
# Repository
|
|
2
|
+
|
|
3
|
+
the repository structure:
|
|
4
|
+
```
|
|
5
|
+
├── index.yaml
|
|
6
|
+
└── example dir 1
|
|
7
|
+
├── example code file.py
|
|
8
|
+
└── index.yaml
|
|
9
|
+
```
|
|
10
|
+
repository is a collection of script, and each script is a collection of file, the `index.yaml` in repository is used to index the script in repository, and the `index.yaml` in script is used to index the file in script.
|
|
11
|
+
|
|
12
|
+
The program will ignore folders that do not contain an index.yaml file.
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
## Content
|
|
16
|
+
|
|
17
|
+
### Repository index.yaml
|
|
18
|
+
|
|
19
|
+
example:
|
|
20
|
+
```yaml
|
|
21
|
+
name: File
|
|
22
|
+
scripts:
|
|
23
|
+
- Z2V0RmlsZUNvdW50
|
|
24
|
+
- WDdadawdwadsadad
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
+ `name`: the name of repository
|
|
28
|
+
+ `scripts`: the list of script in repository, just folder name,not script name
|
|
29
|
+
|
|
30
|
+
### script index.yaml
|
|
31
|
+
|
|
32
|
+
example:
|
|
33
|
+
```yaml
|
|
34
|
+
name: Z2V0RmlsZUNvdW50
|
|
35
|
+
version: 0.0.1
|
|
36
|
+
description: get current folder repository count
|
|
37
|
+
author: Jared3Dev
|
|
38
|
+
email: ruxia.tjy@qq.com
|
|
39
|
+
run: getfilecount.py
|
|
40
|
+
src:
|
|
41
|
+
- getfilecount.py
|
|
42
|
+
license: MIT
|
|
43
|
+
````
|
|
44
|
+
|
|
45
|
+
+ `name`: the name of script
|
|
46
|
+
+ `version`: the version of script
|
|
47
|
+
+ `description`: the description of script
|
|
48
|
+
+ `author`: the author of script
|
|
49
|
+
+ `email`: the email of author
|
|
50
|
+
+ `run`: the file name of script to run, must in src list
|
|
51
|
+
+ `src`: the list of file name of script, just file name,not path
|
|
52
|
+
+ `license`: the license of script
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
# TUtils Documentation
|
|
2
|
+
|
|
3
|
+
TUtils is a modular Python toolkit designed to provide reusable utilities,
|
|
4
|
+
CLI tooling, and extensible core components for building scalable applications.
|
|
5
|
+
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
## Overview
|
|
9
|
+
|
|
10
|
+
This documentation describes how to install, use, extend, and maintain TUtils.
|
|
11
|
+
|
|
12
|
+
---
|
|
13
|
+
|
|
14
|
+
## Getting Started
|
|
15
|
+
|
|
16
|
+
If you are new to TUtils, start here:
|
|
17
|
+
|
|
18
|
+
1. [Installation](installation.md)
|
|
19
|
+
2. [Quick Start](quickstart.md)
|
|
20
|
+
|
|
21
|
+
---
|
|
22
|
+
|
|
23
|
+
## Documentation Structure
|
|
24
|
+
|
|
25
|
+
### User Guide
|
|
26
|
+
- Installation
|
|
27
|
+
- Quick Start
|
|
28
|
+
- CLI Usage
|
|
29
|
+
- Configuration
|
|
30
|
+
|
|
31
|
+
### Architecture
|
|
32
|
+
- System design
|
|
33
|
+
- Module responsibilities
|
|
34
|
+
- Data flow
|
|
35
|
+
|
|
36
|
+
### API Reference
|
|
37
|
+
- Public classes
|
|
38
|
+
- Public functions
|
|
39
|
+
- Usage examples
|
|
40
|
+
|
|
41
|
+
### Development Guide
|
|
42
|
+
- Development setup
|
|
43
|
+
- Coding conventions
|
|
44
|
+
- Release process
|
|
45
|
+
|
|
46
|
+
---
|
|
47
|
+
|
|
48
|
+
## Project Structure
|
|
49
|
+
|
|
50
|
+
The project follows a modular structure:
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
├── assets/
|
|
54
|
+
|
|
55
|
+
├── doc/
|
|
56
|
+
|
|
57
|
+
├── examples/
|
|
58
|
+
|
|
59
|
+
├── test/
|
|
60
|
+
|
|
61
|
+
├── tutils/
|
|
62
|
+
|
|
63
|
+
├── pyproject.toml
|
|
64
|
+
|
|
65
|
+
├── README.md
|
|
66
|
+
|
|
67
|
+
└── devbuild.sh
|
|
68
|
+
|
|
69
|
+
The `docs/` directory contains all project documentation and is versioned alongside the source code.
|
|
70
|
+
|
|
71
|
+
---
|
|
72
|
+
|
|
73
|
+
## Design Philosophy
|
|
74
|
+
|
|
75
|
+
TUtils is built around the following principles:
|
|
76
|
+
|
|
77
|
+
- Clear separation of concerns
|
|
78
|
+
- Minimal global state
|
|
79
|
+
- Predictable configuration management
|
|
80
|
+
- Testability as a first-class requirement
|
|
81
|
+
|
|
82
|
+
---
|
|
83
|
+
|
|
84
|
+
## Contributing
|
|
85
|
+
|
|
86
|
+
If you plan to contribute:
|
|
87
|
+
|
|
88
|
+
- Follow the development guide
|
|
89
|
+
- Ensure tests pass
|
|
90
|
+
- Maintain consistent code style
|
|
91
|
+
- Keep documentation updated with code changes
|
|
92
|
+
|
|
93
|
+
---
|
|
94
|
+
|
|
95
|
+
## License
|
|
96
|
+
|
|
97
|
+
Refer to the root repository license file for details.
|
|
98
|
+
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
## Quick Start
|
|
2
|
+
|
|
3
|
+
after installing TUtils, you can quickly get started by running the following command in your terminal:
|
|
4
|
+
|
|
5
|
+
```bash
|
|
6
|
+
tutils --help
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
This will run `getFileCount.py` in `~/.tutils/Scripts/`, and show the result in terminal.
|
|
10
|
+
|
|
11
|
+
you should add `:` before it if you want use arguments to run script.
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
tutils run getFileCount :show
|
|
15
|
+
```
|
|
16
|
+
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import os
|
|
2
|
+
from pathlib import Path
|
|
3
|
+
from typing import Annotated
|
|
4
|
+
from rich.console import Console
|
|
5
|
+
import typer
|
|
6
|
+
|
|
7
|
+
app = typer.Typer(
|
|
8
|
+
name='TCount',
|
|
9
|
+
help="Count all files in folder",
|
|
10
|
+
)
|
|
11
|
+
|
|
12
|
+
@app.command()
|
|
13
|
+
def main(
|
|
14
|
+
path:Annotated[
|
|
15
|
+
Path,
|
|
16
|
+
typer.Argument(..., help="Path to count files in")
|
|
17
|
+
] = Path.cwd(),
|
|
18
|
+
show:Annotated[
|
|
19
|
+
bool,
|
|
20
|
+
typer.Option(
|
|
21
|
+
"--show",
|
|
22
|
+
"-s",
|
|
23
|
+
help="Show all files and folders",
|
|
24
|
+
is_flag=True,
|
|
25
|
+
)
|
|
26
|
+
] = False,
|
|
27
|
+
):
|
|
28
|
+
console = Console()
|
|
29
|
+
|
|
30
|
+
if not os.path.exists(path):
|
|
31
|
+
console.print("[red]The path does not exist![/red]")
|
|
32
|
+
return 0
|
|
33
|
+
|
|
34
|
+
fileCount = 0
|
|
35
|
+
dirCount = 0
|
|
36
|
+
|
|
37
|
+
for root, dirs, files in os.walk(path):
|
|
38
|
+
dirCount += len(dirs)
|
|
39
|
+
fileCount += len(files)
|
|
40
|
+
|
|
41
|
+
for dir in dirs:
|
|
42
|
+
if show: console.print(os.path.join(root, dir),style='bold yellow')
|
|
43
|
+
|
|
44
|
+
for file in files:
|
|
45
|
+
if show:console.print(os.path.join(root, file),style='#af00ff')
|
|
46
|
+
|
|
47
|
+
console.rule()
|
|
48
|
+
console.print(f'Files Count:{fileCount}',style='bold green')
|
|
49
|
+
console.print(f'Dirs Count:{dirCount}',style='bold green')
|
|
50
|
+
console.print(f'Total Files:{fileCount + dirCount}',style='bold green')
|
|
51
|
+
return 0
|
|
52
|
+
|
|
53
|
+
if __name__ == "__main__":
|
|
54
|
+
raise SystemExit(app())
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["hatchling"]
|
|
3
|
+
build-backend = "hatchling.build"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "TUtils-cli"
|
|
7
|
+
version = "0.1.0"
|
|
8
|
+
description = "TUtils command-line utility toolkit"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.8"
|
|
11
|
+
license = "MIT"
|
|
12
|
+
authors = [
|
|
13
|
+
{ name = "Jared3Dev",email="ruxia.tjy@qq.com"}
|
|
14
|
+
]
|
|
15
|
+
keywords = ["cli","TUtils","command-line"]
|
|
16
|
+
classifiers = [
|
|
17
|
+
"Environment :: Console",
|
|
18
|
+
"License :: OSI Approved :: MIT License",
|
|
19
|
+
]
|
|
20
|
+
dependencies = [
|
|
21
|
+
"typer>=0.23.1",
|
|
22
|
+
"rich",
|
|
23
|
+
"pyyaml>=6.0", # YAML 配置支持
|
|
24
|
+
"pydantic>=1.10.0", # 数据验证
|
|
25
|
+
]
|
|
26
|
+
|
|
27
|
+
[project.scripts]
|
|
28
|
+
tutils = "tutils.cli:app"
|
|
29
|
+
|
|
30
|
+
[project.urls]
|
|
31
|
+
Homepage = "https://github.com/ruxia-TJY/TUtils"
|
|
32
|
+
Documentation = "https://github.com/ruxia-TJY/TUtils"
|
|
33
|
+
Repository = "https://github.com/ruxia-TJY/TUtils.git"
|
|
34
|
+
"Bug Tracker" = "https://github.com/ruxia-TJY/TUtils/issues"
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
[tool.hatch.build.targets.wheel]
|
|
38
|
+
packages = ["tutils"]
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"""Tests for CLI module."""
|
|
2
|
+
|
|
3
|
+
import pytest
|
|
4
|
+
from typer.testing import CliRunner
|
|
5
|
+
|
|
6
|
+
import tutils
|
|
7
|
+
from tutils.cli import app
|
|
8
|
+
|
|
9
|
+
runner = CliRunner()
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
class TestMainCommands:
|
|
13
|
+
"""Test main commands."""
|
|
14
|
+
|
|
15
|
+
def test_version_command(self) -> None:
|
|
16
|
+
"""Test version command."""
|
|
17
|
+
test_cmd = ["version","-v","--version"]
|
|
18
|
+
for cmd in test_cmd:
|
|
19
|
+
result = runner.invoke(app, [cmd])
|
|
20
|
+
assert result.exit_code == 0
|
|
21
|
+
assert tutils.__version__ in result.output
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"""TUtils - A command-line tool."""
|
|
2
|
+
import platform
|
|
3
|
+
from .env import env
|
|
4
|
+
import pathlib
|
|
5
|
+
from . import const as C
|
|
6
|
+
|
|
7
|
+
# 在模块导入时自动初始化配置
|
|
8
|
+
from .config import init_config
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
# 初始化配置(使用默认位置 ~/.tutils/config.yaml)
|
|
12
|
+
_config_manager = init_config()
|
|
13
|
+
|
|
14
|
+
__version__ = C.version
|
|
15
|
+
__author__ = C.author
|
|
16
|
+
__email__ = C.email
|
|
17
|
+
|
|
18
|
+
__all__ = ["__version__", "__author__", "__email__", "init_config"]
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
env.OS_TYPE = platform.system()
|
|
22
|
+
env.WORK_DIR = pathlib.Path.cwd()
|