quickie-runner 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.
- quickie_runner-0.1.0/.editorconfig +27 -0
- quickie_runner-0.1.0/.gitignore +16 -0
- quickie_runner-0.1.0/.pre-commit-config.yaml +44 -0
- quickie_runner-0.1.0/CHANGELOG.md +5 -0
- quickie_runner-0.1.0/LICENSE +21 -0
- quickie_runner-0.1.0/PKG-INFO +153 -0
- quickie_runner-0.1.0/README.md +102 -0
- quickie_runner-0.1.0/pyproject.toml +91 -0
- quickie_runner-0.1.0/src/quickie/__init__.py +12 -0
- quickie_runner-0.1.0/src/quickie/__main__.py +17 -0
- quickie_runner-0.1.0/src/quickie/_meta.py +7 -0
- quickie_runner-0.1.0/src/quickie/_version.py +5 -0
- quickie_runner-0.1.0/src/quickie/argparser.py +73 -0
- quickie_runner-0.1.0/src/quickie/cli.py +193 -0
- quickie_runner-0.1.0/src/quickie/completion/__init__.py +0 -0
- quickie_runner-0.1.0/src/quickie/completion/_internal.py +31 -0
- quickie_runner-0.1.0/src/quickie/completion/base.py +78 -0
- quickie_runner-0.1.0/src/quickie/completion/python.py +84 -0
- quickie_runner-0.1.0/src/quickie/constants.py +18 -0
- quickie_runner-0.1.0/src/quickie/context.py +33 -0
- quickie_runner-0.1.0/src/quickie/errors.py +26 -0
- quickie_runner-0.1.0/src/quickie/loader.py +54 -0
- quickie_runner-0.1.0/src/quickie/namespace.py +109 -0
- quickie_runner-0.1.0/src/quickie/tasks.py +432 -0
- quickie_runner-0.1.0/src/quickie/utils/__init__.py +1 -0
- quickie_runner-0.1.0/src/quickie/utils/imports.py +89 -0
- quickie_runner-0.1.0/tests/__init__.py +0 -0
- quickie_runner-0.1.0/tests/__quickie_test/__init__.py +21 -0
- quickie_runner-0.1.0/tests/__quickie_test/nested.py +15 -0
- quickie_runner-0.1.0/tests/conftest.py +33 -0
- quickie_runner-0.1.0/tests/test_cli.py +202 -0
- quickie_runner-0.1.0/tests/test_completion.py +132 -0
- quickie_runner-0.1.0/tests/test_context.py +10 -0
- quickie_runner-0.1.0/tests/test_tasks.py +341 -0
- quickie_runner-0.1.0/tests/test_utils/test_imports.py +12 -0
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# http://editorconfig.org
|
|
2
|
+
|
|
3
|
+
root = true
|
|
4
|
+
|
|
5
|
+
[*]
|
|
6
|
+
charset = utf-8
|
|
7
|
+
end_of_line = lf
|
|
8
|
+
insert_final_newline = true
|
|
9
|
+
trim_trailing_whitespace = true
|
|
10
|
+
|
|
11
|
+
[*.{py,rst,ini}]
|
|
12
|
+
indent_style = space
|
|
13
|
+
indent_size = 4
|
|
14
|
+
|
|
15
|
+
[*.{html,css,scss,json,yml,xml}]
|
|
16
|
+
indent_style = space
|
|
17
|
+
indent_size = 2
|
|
18
|
+
|
|
19
|
+
[*.md]
|
|
20
|
+
trim_trailing_whitespace = false
|
|
21
|
+
|
|
22
|
+
[Makefile]
|
|
23
|
+
indent_style = tab
|
|
24
|
+
|
|
25
|
+
[nginx.conf]
|
|
26
|
+
indent_style = space
|
|
27
|
+
indent_size = 2
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
default_stages: [commit]
|
|
2
|
+
|
|
3
|
+
default_language_version:
|
|
4
|
+
python: python3.12 # Change if we upgrade python
|
|
5
|
+
|
|
6
|
+
repos:
|
|
7
|
+
- repo: https://github.com/pre-commit/pre-commit-hooks
|
|
8
|
+
rev: v4.5.0
|
|
9
|
+
hooks:
|
|
10
|
+
- id: trailing-whitespace
|
|
11
|
+
- id: end-of-file-fixer
|
|
12
|
+
- id: check-json
|
|
13
|
+
- id: check-toml
|
|
14
|
+
- id: check-xml
|
|
15
|
+
- id: check-yaml
|
|
16
|
+
- id: debug-statements
|
|
17
|
+
- id: check-builtin-literals
|
|
18
|
+
- id: check-case-conflict
|
|
19
|
+
- id: check-merge-conflict
|
|
20
|
+
- id: detect-private-key
|
|
21
|
+
|
|
22
|
+
- repo: https://github.com/asottile/pyupgrade
|
|
23
|
+
rev: v3.15.0
|
|
24
|
+
hooks:
|
|
25
|
+
- id: pyupgrade
|
|
26
|
+
args: [--py312-plus] # Change if we upgrade python
|
|
27
|
+
exclude: hooks/
|
|
28
|
+
|
|
29
|
+
- repo: https://github.com/PyCQA/isort
|
|
30
|
+
rev: 5.13.2
|
|
31
|
+
hooks:
|
|
32
|
+
- id: isort
|
|
33
|
+
# Fixes compatibility issues with black
|
|
34
|
+
args: [--profile=black]
|
|
35
|
+
|
|
36
|
+
- repo: https://github.com/psf/black
|
|
37
|
+
rev: 23.12.1
|
|
38
|
+
hooks:
|
|
39
|
+
- id: black
|
|
40
|
+
|
|
41
|
+
ci:
|
|
42
|
+
autoupdate_schedule: weekly
|
|
43
|
+
skip: []
|
|
44
|
+
submodules: false
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License
|
|
2
|
+
|
|
3
|
+
Copyright 2024 Adrian Martinez Rodriguez <adrianmrit@gmail.com>
|
|
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
|
|
13
|
+
all 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
|
|
21
|
+
THE SOFTWARE.
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
Metadata-Version: 2.3
|
|
2
|
+
Name: quickie-runner
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: A CLI tool for quick tasks.
|
|
5
|
+
Project-URL: Homepage, https://github.com/adrianmrit/quickie
|
|
6
|
+
Project-URL: Repository, https://github.com/adrianmrit/quickie.git
|
|
7
|
+
Project-URL: Issues, https://github.com/adrianmrit/quickie/issues
|
|
8
|
+
Project-URL: Changelog, https://github.com/adrianmrit/quickie/blob/main/CHANGELOG.md
|
|
9
|
+
Author-email: Author Name <author@example.com>
|
|
10
|
+
License: The MIT License
|
|
11
|
+
|
|
12
|
+
Copyright 2024 Adrian Martinez Rodriguez <adrianmrit@gmail.com>
|
|
13
|
+
|
|
14
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
15
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
16
|
+
in the Software without restriction, including without limitation the rights
|
|
17
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
18
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
19
|
+
furnished to do so, subject to the following conditions:
|
|
20
|
+
|
|
21
|
+
The above copyright notice and this permission notice shall be included in
|
|
22
|
+
all copies or substantial portions of the Software.
|
|
23
|
+
|
|
24
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
25
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
26
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
27
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
28
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
29
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
30
|
+
THE SOFTWARE.
|
|
31
|
+
License-File: LICENSE
|
|
32
|
+
Keywords: CLI,quick,tasks
|
|
33
|
+
Classifier: Development Status :: 3 - Alpha
|
|
34
|
+
Classifier: Environment :: Console
|
|
35
|
+
Classifier: Intended Audience :: Developers
|
|
36
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
37
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
38
|
+
Requires-Python: >=3.12
|
|
39
|
+
Requires-Dist: argcomplete~=3.5.0
|
|
40
|
+
Requires-Dist: classoptions~=0.2.0
|
|
41
|
+
Requires-Dist: frozendict~=2.4.4
|
|
42
|
+
Requires-Dist: oslex~=0.1.3
|
|
43
|
+
Requires-Dist: python-dotenv~=1.0.1
|
|
44
|
+
Requires-Dist: rich~=13.7.1
|
|
45
|
+
Provides-Extra: dev
|
|
46
|
+
Requires-Dist: mock; extra == 'dev'
|
|
47
|
+
Requires-Dist: pytest; extra == 'dev'
|
|
48
|
+
Requires-Dist: pytest-cov; extra == 'dev'
|
|
49
|
+
Requires-Dist: pytest-mock; extra == 'dev'
|
|
50
|
+
Description-Content-Type: text/markdown
|
|
51
|
+
|
|
52
|
+
# Quickie - A CLI tool for quick tasks
|
|
53
|
+
|
|
54
|
+
[](https://github.com/adrianmrit/quickie/blob/master/LICENSE)
|
|
55
|
+
|
|
56
|
+
## Getting Started
|
|
57
|
+
|
|
58
|
+
### Prerequisites
|
|
59
|
+
|
|
60
|
+
Some prerequisites need to be installed.
|
|
61
|
+
|
|
62
|
+
- Python 3.12+
|
|
63
|
+
|
|
64
|
+
### Installing
|
|
65
|
+
|
|
66
|
+
The recommended way to install `quickie` is via `pipx`.
|
|
67
|
+
|
|
68
|
+
With `pipx` you can add the `qck` command and the package in an isolated environment, without polluting your global Python environment.
|
|
69
|
+
|
|
70
|
+
See the [pipx installation instructions](https://pipx.pypa.io/stable/installation/)
|
|
71
|
+
|
|
72
|
+
After installing `pipx`, you can install `quickie` with the following command:
|
|
73
|
+
|
|
74
|
+
```sh
|
|
75
|
+
pipx install quickie-runner
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
You can also install `quickie` with `pip`:
|
|
79
|
+
|
|
80
|
+
```sh
|
|
81
|
+
pip install quickie-runner
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
## Tab completion
|
|
85
|
+
|
|
86
|
+
Tab completion is available for bash and zsh. It depends on the `argcomplete` package, which should have been installed with `quickie`.
|
|
87
|
+
|
|
88
|
+
To enable tab completion for `quickie`, add the following line to your `.bashrc` or `.zshrc`:
|
|
89
|
+
|
|
90
|
+
```sh
|
|
91
|
+
eval "$(register-python-argcomplete qck)"
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
If you get the following error in the zsh shell:
|
|
95
|
+
|
|
96
|
+
```sh
|
|
97
|
+
complete:13: command not found: compdef
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
You can fix it by adding the following line to your `.zshrc` (before the line that registers the completion):
|
|
101
|
+
|
|
102
|
+
```sh
|
|
103
|
+
autoload -Uz compinit && compinit
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
## Usage
|
|
107
|
+
|
|
108
|
+
Tasks are configured under a `__quickie.py` or `__quickie` python module in the current directory.
|
|
109
|
+
If using a `__quickie` directory, the tasks are defined in the `__quickie/__init__.py` file.
|
|
110
|
+
|
|
111
|
+
Tasks are defined as classes, though factory functions are also supported.
|
|
112
|
+
|
|
113
|
+
### Why define tasks in Python?
|
|
114
|
+
|
|
115
|
+
While many existing similar tools use YAML, TOML or custom formats to define tasks, `quickie` uses Python for the following reasons:
|
|
116
|
+
|
|
117
|
+
- Built-in syntax highlighting and linting
|
|
118
|
+
- Supported by most editors and IDEs
|
|
119
|
+
- Easy to use and understand
|
|
120
|
+
- Extensible and powerful
|
|
121
|
+
|
|
122
|
+
### Quick Example
|
|
123
|
+
|
|
124
|
+
Here is a simple example of a `__quickie.py` file:
|
|
125
|
+
|
|
126
|
+
```python
|
|
127
|
+
from quickie.tasks import Task, ScriptTask
|
|
128
|
+
|
|
129
|
+
class hello(Task):
|
|
130
|
+
def run(self):
|
|
131
|
+
print("Hello, world!")
|
|
132
|
+
|
|
133
|
+
|
|
134
|
+
class ScriptTaskExample(ScriptTask):
|
|
135
|
+
class Meta:
|
|
136
|
+
alias = "echo"
|
|
137
|
+
allow_unknown_args = True
|
|
138
|
+
|
|
139
|
+
def get_script(self, *args):
|
|
140
|
+
return " ".join(["echo", *args])
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
You can run the `Hello` task with the following command:
|
|
144
|
+
|
|
145
|
+
```sh
|
|
146
|
+
qck hello
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
And the `ScriptTaskExample` task with:
|
|
150
|
+
|
|
151
|
+
```sh
|
|
152
|
+
qck echo "Hello, world!"
|
|
153
|
+
```
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
# Quickie - A CLI tool for quick tasks
|
|
2
|
+
|
|
3
|
+
[](https://github.com/adrianmrit/quickie/blob/master/LICENSE)
|
|
4
|
+
|
|
5
|
+
## Getting Started
|
|
6
|
+
|
|
7
|
+
### Prerequisites
|
|
8
|
+
|
|
9
|
+
Some prerequisites need to be installed.
|
|
10
|
+
|
|
11
|
+
- Python 3.12+
|
|
12
|
+
|
|
13
|
+
### Installing
|
|
14
|
+
|
|
15
|
+
The recommended way to install `quickie` is via `pipx`.
|
|
16
|
+
|
|
17
|
+
With `pipx` you can add the `qck` command and the package in an isolated environment, without polluting your global Python environment.
|
|
18
|
+
|
|
19
|
+
See the [pipx installation instructions](https://pipx.pypa.io/stable/installation/)
|
|
20
|
+
|
|
21
|
+
After installing `pipx`, you can install `quickie` with the following command:
|
|
22
|
+
|
|
23
|
+
```sh
|
|
24
|
+
pipx install quickie-runner
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
You can also install `quickie` with `pip`:
|
|
28
|
+
|
|
29
|
+
```sh
|
|
30
|
+
pip install quickie-runner
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
## Tab completion
|
|
34
|
+
|
|
35
|
+
Tab completion is available for bash and zsh. It depends on the `argcomplete` package, which should have been installed with `quickie`.
|
|
36
|
+
|
|
37
|
+
To enable tab completion for `quickie`, add the following line to your `.bashrc` or `.zshrc`:
|
|
38
|
+
|
|
39
|
+
```sh
|
|
40
|
+
eval "$(register-python-argcomplete qck)"
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
If you get the following error in the zsh shell:
|
|
44
|
+
|
|
45
|
+
```sh
|
|
46
|
+
complete:13: command not found: compdef
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
You can fix it by adding the following line to your `.zshrc` (before the line that registers the completion):
|
|
50
|
+
|
|
51
|
+
```sh
|
|
52
|
+
autoload -Uz compinit && compinit
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
## Usage
|
|
56
|
+
|
|
57
|
+
Tasks are configured under a `__quickie.py` or `__quickie` python module in the current directory.
|
|
58
|
+
If using a `__quickie` directory, the tasks are defined in the `__quickie/__init__.py` file.
|
|
59
|
+
|
|
60
|
+
Tasks are defined as classes, though factory functions are also supported.
|
|
61
|
+
|
|
62
|
+
### Why define tasks in Python?
|
|
63
|
+
|
|
64
|
+
While many existing similar tools use YAML, TOML or custom formats to define tasks, `quickie` uses Python for the following reasons:
|
|
65
|
+
|
|
66
|
+
- Built-in syntax highlighting and linting
|
|
67
|
+
- Supported by most editors and IDEs
|
|
68
|
+
- Easy to use and understand
|
|
69
|
+
- Extensible and powerful
|
|
70
|
+
|
|
71
|
+
### Quick Example
|
|
72
|
+
|
|
73
|
+
Here is a simple example of a `__quickie.py` file:
|
|
74
|
+
|
|
75
|
+
```python
|
|
76
|
+
from quickie.tasks import Task, ScriptTask
|
|
77
|
+
|
|
78
|
+
class hello(Task):
|
|
79
|
+
def run(self):
|
|
80
|
+
print("Hello, world!")
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
class ScriptTaskExample(ScriptTask):
|
|
84
|
+
class Meta:
|
|
85
|
+
alias = "echo"
|
|
86
|
+
allow_unknown_args = True
|
|
87
|
+
|
|
88
|
+
def get_script(self, *args):
|
|
89
|
+
return " ".join(["echo", *args])
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
You can run the `Hello` task with the following command:
|
|
93
|
+
|
|
94
|
+
```sh
|
|
95
|
+
qck hello
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
And the `ScriptTaskExample` task with:
|
|
99
|
+
|
|
100
|
+
```sh
|
|
101
|
+
qck echo "Hello, world!"
|
|
102
|
+
```
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["hatchling"]
|
|
3
|
+
build-backend = "hatchling.build"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "quickie-runner"
|
|
7
|
+
dynamic = ["version"]
|
|
8
|
+
description = "A CLI tool for quick tasks."
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
authors = [
|
|
11
|
+
{ name = "Author Name", email = "author@example.com" }
|
|
12
|
+
]
|
|
13
|
+
license = { file = "LICENSE" }
|
|
14
|
+
# url = { "Homepage" = "https://example.com" }
|
|
15
|
+
keywords = ["CLI", "quick", "tasks"]
|
|
16
|
+
classifiers = [
|
|
17
|
+
"Development Status :: 3 - Alpha",
|
|
18
|
+
"Environment :: Console",
|
|
19
|
+
"Intended Audience :: Developers",
|
|
20
|
+
"Programming Language :: Python :: 3.12",
|
|
21
|
+
"License :: OSI Approved :: MIT License",
|
|
22
|
+
]
|
|
23
|
+
requires-python = ">=3.12"
|
|
24
|
+
dependencies=[
|
|
25
|
+
"classoptions~=0.2.0",
|
|
26
|
+
"frozendict~=2.4.4",
|
|
27
|
+
"oslex~=0.1.3",
|
|
28
|
+
"python-dotenv~=1.0.1",
|
|
29
|
+
"rich~=13.7.1",
|
|
30
|
+
"argcomplete~=3.5.0",
|
|
31
|
+
]
|
|
32
|
+
|
|
33
|
+
[project.urls]
|
|
34
|
+
Homepage = "https://github.com/adrianmrit/quickie"
|
|
35
|
+
Repository = "https://github.com/adrianmrit/quickie.git"
|
|
36
|
+
Issues = "https://github.com/adrianmrit/quickie/issues"
|
|
37
|
+
Changelog = "https://github.com/adrianmrit/quickie/blob/main/CHANGELOG.md"
|
|
38
|
+
|
|
39
|
+
[project.optional-dependencies]
|
|
40
|
+
dev = [
|
|
41
|
+
"mock",
|
|
42
|
+
"pytest",
|
|
43
|
+
"pytest-cov",
|
|
44
|
+
"pytest-mock"
|
|
45
|
+
]
|
|
46
|
+
|
|
47
|
+
[project.scripts]
|
|
48
|
+
"qck" = "quickie.cli:main"
|
|
49
|
+
|
|
50
|
+
[tool.hatch.build.targets.wheel]
|
|
51
|
+
packages = ["src/quickie"]
|
|
52
|
+
|
|
53
|
+
[tool.hatch.version]
|
|
54
|
+
path = "src/quickie/_meta.py"
|
|
55
|
+
|
|
56
|
+
[tool.hatch.build]
|
|
57
|
+
exclude = ["__quickie"]
|
|
58
|
+
|
|
59
|
+
[tool.pytest.ini_options]
|
|
60
|
+
addopts = ["-vv"]
|
|
61
|
+
markers = [
|
|
62
|
+
"unit",
|
|
63
|
+
"integration"
|
|
64
|
+
]
|
|
65
|
+
python_files = "tests/*.py"
|
|
66
|
+
mock_use_standalone_module = true
|
|
67
|
+
|
|
68
|
+
[tool.coverage.run]
|
|
69
|
+
source = ["src/quickie"]
|
|
70
|
+
omit = [
|
|
71
|
+
"tests/*",
|
|
72
|
+
"__quickie/*"
|
|
73
|
+
]
|
|
74
|
+
|
|
75
|
+
[tool.ruff]
|
|
76
|
+
|
|
77
|
+
[tool.ruff.lint]
|
|
78
|
+
select = [
|
|
79
|
+
"PL", # pylint
|
|
80
|
+
"E", # pycodestyle
|
|
81
|
+
"F", # pyflakes
|
|
82
|
+
"D", # pydocstyle
|
|
83
|
+
]
|
|
84
|
+
fixable = ["ALL"]
|
|
85
|
+
ignore = ["D106"]
|
|
86
|
+
|
|
87
|
+
[tool.ruff.lint.pydocstyle]
|
|
88
|
+
convention = "google"
|
|
89
|
+
|
|
90
|
+
[tool.ruff.lint.per-file-ignores]
|
|
91
|
+
"tests/*" = ["D"]
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
#!/usr/bin/env python
|
|
2
|
+
# PYTHON_ARGCOMPLETE_OK
|
|
3
|
+
"""A CLI tool for quick tasks."""
|
|
4
|
+
from ._meta import __author__, __copyright__, __email__, __home__, __version__
|
|
5
|
+
|
|
6
|
+
__all__ = [
|
|
7
|
+
"__author__",
|
|
8
|
+
"__copyright__",
|
|
9
|
+
"__email__",
|
|
10
|
+
"__home__",
|
|
11
|
+
"__version__",
|
|
12
|
+
]
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
#!/usr/bin/env python
|
|
2
|
+
# PYTHON_ARGCOMPLETE_OK
|
|
3
|
+
"""Entry point for the application script."""
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
import sys
|
|
7
|
+
|
|
8
|
+
from .cli import main
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
def _run_main():
|
|
12
|
+
if __name__ == "__main__":
|
|
13
|
+
argv = sys.argv[1:]
|
|
14
|
+
main(argv)
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
_run_main()
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
"""Custom argument parser for quickie."""
|
|
2
|
+
|
|
3
|
+
import typing
|
|
4
|
+
from argparse import ArgumentParser
|
|
5
|
+
|
|
6
|
+
import argcomplete
|
|
7
|
+
|
|
8
|
+
from quickie._meta import __version__ as version
|
|
9
|
+
from quickie.completion._internal import TaskCompleter
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
class ArgumentsParser(ArgumentParser):
|
|
13
|
+
"""Custom argument parser for quickie."""
|
|
14
|
+
|
|
15
|
+
@typing.override
|
|
16
|
+
def __init__(self, main):
|
|
17
|
+
super().__init__(description="A CLI tool for quick tasks.")
|
|
18
|
+
module_or_global_group = self.add_mutually_exclusive_group()
|
|
19
|
+
self.add_argument("-V", "--version", action="version", version=version)
|
|
20
|
+
self.add_argument("-l", "--list", action="store_true", help="List tasks")
|
|
21
|
+
module_or_global_group.add_argument(
|
|
22
|
+
"-m", "--module", type=str, help="The module to load tasks from"
|
|
23
|
+
)
|
|
24
|
+
module_or_global_group.add_argument(
|
|
25
|
+
"-g",
|
|
26
|
+
"--global",
|
|
27
|
+
action="store_true",
|
|
28
|
+
help="Use global defined tasks",
|
|
29
|
+
dest="use_global",
|
|
30
|
+
)
|
|
31
|
+
module_or_global_group.add_argument(
|
|
32
|
+
"--autocomplete",
|
|
33
|
+
help="Suggest autocompletion for the shell",
|
|
34
|
+
dest="suggest_auto_completion",
|
|
35
|
+
choices=["bash", "zsh"],
|
|
36
|
+
).completer = argcomplete.ChoicesCompleter(["bash", "zsh"])
|
|
37
|
+
self.add_argument(
|
|
38
|
+
"task", nargs="?", help="The task to run"
|
|
39
|
+
).completer = TaskCompleter(main)
|
|
40
|
+
# This does not need completion as it is handled by the task completer
|
|
41
|
+
self.add_argument("args", nargs="*", help="The arguments to pass to the task")
|
|
42
|
+
|
|
43
|
+
@typing.override
|
|
44
|
+
def parse_known_args(self, args=None, namespace=None):
|
|
45
|
+
qck_args, task_args = self._partition_args(args)
|
|
46
|
+
namespace, argv = super().parse_known_args(qck_args, namespace)
|
|
47
|
+
|
|
48
|
+
if argv:
|
|
49
|
+
# Because the unknown arguments are not task arguments, we raise an error
|
|
50
|
+
msg = "unrecognized arguments: %s"
|
|
51
|
+
self.error(msg % " ".join(argv))
|
|
52
|
+
|
|
53
|
+
# namespace.task = task
|
|
54
|
+
namespace.args = task_args
|
|
55
|
+
return namespace, []
|
|
56
|
+
|
|
57
|
+
def _partition_args(self, args):
|
|
58
|
+
qck_args = []
|
|
59
|
+
task_args = []
|
|
60
|
+
args = iter(args)
|
|
61
|
+
while arg := next(args, None):
|
|
62
|
+
if arg in {"-m", "--module", "--autocomplete"}:
|
|
63
|
+
qck_args.append(arg)
|
|
64
|
+
qck_args.append(next(args))
|
|
65
|
+
elif arg.startswith("-"):
|
|
66
|
+
qck_args.append(arg)
|
|
67
|
+
else:
|
|
68
|
+
# Task found
|
|
69
|
+
qck_args.append(arg)
|
|
70
|
+
# The rest of the arguments are task arguments
|
|
71
|
+
task_args = list(args)
|
|
72
|
+
|
|
73
|
+
return qck_args, task_args
|