aap2 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.
- aap2-0.1.0/LICENSE +21 -0
- aap2-0.1.0/PKG-INFO +304 -0
- aap2-0.1.0/README.md +272 -0
- aap2-0.1.0/aap/__init__.py +11 -0
- aap2-0.1.0/aap/core.py +193 -0
- aap2-0.1.0/aap/parser.py +197 -0
- aap2-0.1.0/aap2.egg-info/PKG-INFO +304 -0
- aap2-0.1.0/aap2.egg-info/SOURCES.txt +17 -0
- aap2-0.1.0/aap2.egg-info/dependency_links.txt +1 -0
- aap2-0.1.0/aap2.egg-info/requires.txt +4 -0
- aap2-0.1.0/aap2.egg-info/top_level.txt +1 -0
- aap2-0.1.0/pyproject.toml +76 -0
- aap2-0.1.0/setup.cfg +4 -0
- aap2-0.1.0/tests/test_core.py +271 -0
- aap2-0.1.0/tests/test_coverage_complete.py +52 -0
- aap2-0.1.0/tests/test_edge_cases.py +44 -0
- aap2-0.1.0/tests/test_full_coverage.py +51 -0
- aap2-0.1.0/tests/test_integration.py +300 -0
- aap2-0.1.0/tests/test_parser.py +203 -0
aap2-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 autoarg contributors
|
|
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.
|
aap2-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,304 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: aap2
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Automatic command-line interface generation for Python functions using type hints and docstrings
|
|
5
|
+
Author: Alex Hagen
|
|
6
|
+
License: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/alexhagen/aap
|
|
8
|
+
Project-URL: Documentation, https://github.com/alexhagen/aap#readme
|
|
9
|
+
Project-URL: Repository, https://github.com/alexhagen/aap
|
|
10
|
+
Project-URL: Issues, https://github.com/alexhagen/aap/issues
|
|
11
|
+
Keywords: cli,argparse,command-line,automation,type-hints,aap
|
|
12
|
+
Classifier: Development Status :: 4 - Beta
|
|
13
|
+
Classifier: Intended Audience :: Developers
|
|
14
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
15
|
+
Classifier: Programming Language :: Python :: 3
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.7
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.8
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
22
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
23
|
+
Classifier: Topic :: System :: Shells
|
|
24
|
+
Classifier: Topic :: Utilities
|
|
25
|
+
Requires-Python: >=3.7
|
|
26
|
+
Description-Content-Type: text/markdown
|
|
27
|
+
License-File: LICENSE
|
|
28
|
+
Provides-Extra: dev
|
|
29
|
+
Requires-Dist: pytest>=7.0.0; extra == "dev"
|
|
30
|
+
Requires-Dist: pytest-cov>=4.0.0; extra == "dev"
|
|
31
|
+
Dynamic: license-file
|
|
32
|
+
|
|
33
|
+
# aap
|
|
34
|
+
|
|
35
|
+
[](https://pypi.org/project/aap/)
|
|
36
|
+
[](https://github.com/alexhagen/aap)
|
|
37
|
+
|
|
38
|
+
Automatic command-line interface generation for Python functions using type hints and docstrings.
|
|
39
|
+
|
|
40
|
+
## Overview
|
|
41
|
+
|
|
42
|
+
`aap` is a Python package that automatically generates command-line interfaces from Python functions. It leverages type hints to determine argument types and parses docstrings to provide helpful descriptions, eliminating the need to manually write argparse boilerplate code.
|
|
43
|
+
|
|
44
|
+
## Features
|
|
45
|
+
|
|
46
|
+
- Automatic CLI generation from function signatures
|
|
47
|
+
- Type inference from Python type hints (str, int, float, bool, List, Optional)
|
|
48
|
+
- Help text extraction from docstrings (Google, NumPy, and reStructuredText styles)
|
|
49
|
+
- Support for default values and optional parameters
|
|
50
|
+
- Boolean flags with automatic handling
|
|
51
|
+
- Multi-command support for creating complex CLIs
|
|
52
|
+
- Warning system for missing type annotations
|
|
53
|
+
|
|
54
|
+
## Installation
|
|
55
|
+
|
|
56
|
+
```bash
|
|
57
|
+
pip install aap
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
Or with uv:
|
|
61
|
+
|
|
62
|
+
```bash
|
|
63
|
+
uv pip install aap
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
## Quick Start
|
|
67
|
+
|
|
68
|
+
### Single Function CLI
|
|
69
|
+
|
|
70
|
+
```python
|
|
71
|
+
from aap import autoarg
|
|
72
|
+
|
|
73
|
+
def greet(name: str, age: int, greeting: str = "Hello"):
|
|
74
|
+
"""Greet a person.
|
|
75
|
+
|
|
76
|
+
Args:
|
|
77
|
+
name: Person's name
|
|
78
|
+
age: Person's age
|
|
79
|
+
greeting: Greeting message to use
|
|
80
|
+
"""
|
|
81
|
+
return f"{greeting} {name}, you are {age} years old"
|
|
82
|
+
|
|
83
|
+
if __name__ == "__main__":
|
|
84
|
+
cli = autoarg(greet)
|
|
85
|
+
result = cli()
|
|
86
|
+
print(result)
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
Run it:
|
|
90
|
+
|
|
91
|
+
```bash
|
|
92
|
+
python script.py --name Alice --age 30
|
|
93
|
+
# Output: Hello Alice, you are 30 years old
|
|
94
|
+
|
|
95
|
+
python script.py --name Bob --age 25 --greeting Hi
|
|
96
|
+
# Output: Hi Bob, you are 25 years old
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
### Multi-Command CLI
|
|
100
|
+
|
|
101
|
+
```python
|
|
102
|
+
from aap import autoarg
|
|
103
|
+
|
|
104
|
+
def add(a: int, b: int):
|
|
105
|
+
"""Add two numbers.
|
|
106
|
+
|
|
107
|
+
Args:
|
|
108
|
+
a: First number
|
|
109
|
+
b: Second number
|
|
110
|
+
"""
|
|
111
|
+
return a + b
|
|
112
|
+
|
|
113
|
+
def multiply(a: int, b: int):
|
|
114
|
+
"""Multiply two numbers.
|
|
115
|
+
|
|
116
|
+
Args:
|
|
117
|
+
a: First number
|
|
118
|
+
b: Second number
|
|
119
|
+
"""
|
|
120
|
+
return a * b
|
|
121
|
+
|
|
122
|
+
if __name__ == "__main__":
|
|
123
|
+
cli = autoarg([add, multiply])
|
|
124
|
+
result = cli()
|
|
125
|
+
print(result)
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
Run it:
|
|
129
|
+
|
|
130
|
+
```bash
|
|
131
|
+
python script.py add --a 5 --b 3
|
|
132
|
+
# Output: 8
|
|
133
|
+
|
|
134
|
+
python script.py multiply --a 5 --b 3
|
|
135
|
+
# Output: 15
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
## Supported Types
|
|
139
|
+
|
|
140
|
+
- **Basic types**: `str`, `int`, `float`, `bool`
|
|
141
|
+
- **Optional types**: `Optional[T]` for optional parameters
|
|
142
|
+
- **List types**: `List[T]` for multiple values
|
|
143
|
+
- **Default values**: Automatically detected from function signatures
|
|
144
|
+
|
|
145
|
+
## Boolean Flags
|
|
146
|
+
|
|
147
|
+
Boolean parameters are automatically converted to flags:
|
|
148
|
+
|
|
149
|
+
```python
|
|
150
|
+
def process(name: str, verbose: bool = False, enabled: bool = True):
|
|
151
|
+
"""Process with flags.
|
|
152
|
+
|
|
153
|
+
Args:
|
|
154
|
+
name: Item name
|
|
155
|
+
verbose: Enable verbose output
|
|
156
|
+
enabled: Whether processing is enabled
|
|
157
|
+
"""
|
|
158
|
+
pass
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
Usage:
|
|
162
|
+
|
|
163
|
+
```bash
|
|
164
|
+
# verbose defaults to False, use --verbose to set True
|
|
165
|
+
python script.py --name test --verbose
|
|
166
|
+
|
|
167
|
+
# enabled defaults to True, use --no-enabled to set False
|
|
168
|
+
python script.py --name test --no-enabled
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
## Docstring Support
|
|
172
|
+
|
|
173
|
+
`autoarg` supports multiple docstring formats:
|
|
174
|
+
|
|
175
|
+
### Google Style
|
|
176
|
+
|
|
177
|
+
```python
|
|
178
|
+
def func(param1: str, param2: int):
|
|
179
|
+
"""Function description.
|
|
180
|
+
|
|
181
|
+
Args:
|
|
182
|
+
param1: Description of param1
|
|
183
|
+
param2: Description of param2
|
|
184
|
+
"""
|
|
185
|
+
pass
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
### NumPy Style
|
|
189
|
+
|
|
190
|
+
```python
|
|
191
|
+
def func(param1: str, param2: int):
|
|
192
|
+
"""Function description.
|
|
193
|
+
|
|
194
|
+
Parameters
|
|
195
|
+
----------
|
|
196
|
+
param1 : str
|
|
197
|
+
Description of param1
|
|
198
|
+
param2 : int
|
|
199
|
+
Description of param2
|
|
200
|
+
"""
|
|
201
|
+
pass
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
### reStructuredText Style
|
|
205
|
+
|
|
206
|
+
```python
|
|
207
|
+
def func(param1: str, param2: int):
|
|
208
|
+
"""Function description.
|
|
209
|
+
|
|
210
|
+
:param param1: Description of param1
|
|
211
|
+
:param param2: Description of param2
|
|
212
|
+
"""
|
|
213
|
+
pass
|
|
214
|
+
```
|
|
215
|
+
|
|
216
|
+
## Advanced Example
|
|
217
|
+
|
|
218
|
+
```python
|
|
219
|
+
from typing import List, Optional
|
|
220
|
+
from aap import autoarg
|
|
221
|
+
|
|
222
|
+
def backup_database(
|
|
223
|
+
host: str,
|
|
224
|
+
database: str,
|
|
225
|
+
output_file: str,
|
|
226
|
+
port: int = 5432,
|
|
227
|
+
username: Optional[str] = None,
|
|
228
|
+
compress: bool = True,
|
|
229
|
+
tables: Optional[List[str]] = None
|
|
230
|
+
):
|
|
231
|
+
"""Backup a PostgreSQL database.
|
|
232
|
+
|
|
233
|
+
Args:
|
|
234
|
+
host: Database host
|
|
235
|
+
database: Database name
|
|
236
|
+
output_file: Output backup file path
|
|
237
|
+
port: Database port
|
|
238
|
+
username: Database username
|
|
239
|
+
compress: Compress the backup file
|
|
240
|
+
tables: Specific tables to backup
|
|
241
|
+
"""
|
|
242
|
+
# Implementation here
|
|
243
|
+
pass
|
|
244
|
+
|
|
245
|
+
if __name__ == "__main__":
|
|
246
|
+
cli = autoarg(backup_database)
|
|
247
|
+
cli()
|
|
248
|
+
```
|
|
249
|
+
|
|
250
|
+
Usage:
|
|
251
|
+
|
|
252
|
+
```bash
|
|
253
|
+
# Basic backup
|
|
254
|
+
python backup.py --host localhost --database mydb --output-file backup.sql
|
|
255
|
+
|
|
256
|
+
# Advanced backup with options
|
|
257
|
+
python backup.py --host db.example.com --database prod \
|
|
258
|
+
--output-file backup.sql --port 3306 --username admin \
|
|
259
|
+
--no-compress --tables users orders products
|
|
260
|
+
```
|
|
261
|
+
|
|
262
|
+
## Type Annotations
|
|
263
|
+
|
|
264
|
+
Type hints are required for proper CLI generation. If a parameter lacks a type annotation, `autoarg` will issue a warning and default to `str` type:
|
|
265
|
+
|
|
266
|
+
```python
|
|
267
|
+
def func(typed_param: int, untyped_param):
|
|
268
|
+
pass
|
|
269
|
+
# Warning: Parameter 'untyped_param' has no type annotation. Defaulting to str type.
|
|
270
|
+
```
|
|
271
|
+
|
|
272
|
+
## Development
|
|
273
|
+
|
|
274
|
+
### Running Tests
|
|
275
|
+
|
|
276
|
+
```bash
|
|
277
|
+
pytest tests/ -v --cov=autoarg --cov-report=term-missing
|
|
278
|
+
```
|
|
279
|
+
|
|
280
|
+
### Building the Package
|
|
281
|
+
|
|
282
|
+
```bash
|
|
283
|
+
python -m build
|
|
284
|
+
```
|
|
285
|
+
|
|
286
|
+
## License
|
|
287
|
+
|
|
288
|
+
MIT License
|
|
289
|
+
|
|
290
|
+
## Contributing
|
|
291
|
+
|
|
292
|
+
Contributions are welcome. Please ensure all tests pass and maintain 100% code coverage for new features.
|
|
293
|
+
|
|
294
|
+
## Generative Artificial Intelligence Disclosure
|
|
295
|
+
|
|
296
|
+
This package was created using Cline and claude-sonnet-4-5 starting from the following prompt:
|
|
297
|
+
|
|
298
|
+
> Create a python package in this directory called aap. Auto arg parse has one functionality. That functionality is to take a callable or a list of callables and return another call, which wraps the input callable and uses python built-in argparse library to receive all input parameters to the call from command line input. Use the python type hints to figure out the type of the input parameters, and use the callable's documentation to figure out descriptions or help messages for the parameters. Throw a warning if a input parameter is not typed. If there are multiple callables passed to aap, create commands for each, with their own parameters parsed.
|
|
299
|
+
>
|
|
300
|
+
> Create a professional concise read me with no emojis.
|
|
301
|
+
>
|
|
302
|
+
> Create tests that use pytest and have a coverage of 100%.
|
|
303
|
+
>
|
|
304
|
+
> Create a pyproject.toml and package for pypi for distribution through pip or uv.
|
aap2-0.1.0/README.md
ADDED
|
@@ -0,0 +1,272 @@
|
|
|
1
|
+
# aap
|
|
2
|
+
|
|
3
|
+
[](https://pypi.org/project/aap/)
|
|
4
|
+
[](https://github.com/alexhagen/aap)
|
|
5
|
+
|
|
6
|
+
Automatic command-line interface generation for Python functions using type hints and docstrings.
|
|
7
|
+
|
|
8
|
+
## Overview
|
|
9
|
+
|
|
10
|
+
`aap` is a Python package that automatically generates command-line interfaces from Python functions. It leverages type hints to determine argument types and parses docstrings to provide helpful descriptions, eliminating the need to manually write argparse boilerplate code.
|
|
11
|
+
|
|
12
|
+
## Features
|
|
13
|
+
|
|
14
|
+
- Automatic CLI generation from function signatures
|
|
15
|
+
- Type inference from Python type hints (str, int, float, bool, List, Optional)
|
|
16
|
+
- Help text extraction from docstrings (Google, NumPy, and reStructuredText styles)
|
|
17
|
+
- Support for default values and optional parameters
|
|
18
|
+
- Boolean flags with automatic handling
|
|
19
|
+
- Multi-command support for creating complex CLIs
|
|
20
|
+
- Warning system for missing type annotations
|
|
21
|
+
|
|
22
|
+
## Installation
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
pip install aap
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
Or with uv:
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
uv pip install aap
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
## Quick Start
|
|
35
|
+
|
|
36
|
+
### Single Function CLI
|
|
37
|
+
|
|
38
|
+
```python
|
|
39
|
+
from aap import autoarg
|
|
40
|
+
|
|
41
|
+
def greet(name: str, age: int, greeting: str = "Hello"):
|
|
42
|
+
"""Greet a person.
|
|
43
|
+
|
|
44
|
+
Args:
|
|
45
|
+
name: Person's name
|
|
46
|
+
age: Person's age
|
|
47
|
+
greeting: Greeting message to use
|
|
48
|
+
"""
|
|
49
|
+
return f"{greeting} {name}, you are {age} years old"
|
|
50
|
+
|
|
51
|
+
if __name__ == "__main__":
|
|
52
|
+
cli = autoarg(greet)
|
|
53
|
+
result = cli()
|
|
54
|
+
print(result)
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
Run it:
|
|
58
|
+
|
|
59
|
+
```bash
|
|
60
|
+
python script.py --name Alice --age 30
|
|
61
|
+
# Output: Hello Alice, you are 30 years old
|
|
62
|
+
|
|
63
|
+
python script.py --name Bob --age 25 --greeting Hi
|
|
64
|
+
# Output: Hi Bob, you are 25 years old
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
### Multi-Command CLI
|
|
68
|
+
|
|
69
|
+
```python
|
|
70
|
+
from aap import autoarg
|
|
71
|
+
|
|
72
|
+
def add(a: int, b: int):
|
|
73
|
+
"""Add two numbers.
|
|
74
|
+
|
|
75
|
+
Args:
|
|
76
|
+
a: First number
|
|
77
|
+
b: Second number
|
|
78
|
+
"""
|
|
79
|
+
return a + b
|
|
80
|
+
|
|
81
|
+
def multiply(a: int, b: int):
|
|
82
|
+
"""Multiply two numbers.
|
|
83
|
+
|
|
84
|
+
Args:
|
|
85
|
+
a: First number
|
|
86
|
+
b: Second number
|
|
87
|
+
"""
|
|
88
|
+
return a * b
|
|
89
|
+
|
|
90
|
+
if __name__ == "__main__":
|
|
91
|
+
cli = autoarg([add, multiply])
|
|
92
|
+
result = cli()
|
|
93
|
+
print(result)
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
Run it:
|
|
97
|
+
|
|
98
|
+
```bash
|
|
99
|
+
python script.py add --a 5 --b 3
|
|
100
|
+
# Output: 8
|
|
101
|
+
|
|
102
|
+
python script.py multiply --a 5 --b 3
|
|
103
|
+
# Output: 15
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
## Supported Types
|
|
107
|
+
|
|
108
|
+
- **Basic types**: `str`, `int`, `float`, `bool`
|
|
109
|
+
- **Optional types**: `Optional[T]` for optional parameters
|
|
110
|
+
- **List types**: `List[T]` for multiple values
|
|
111
|
+
- **Default values**: Automatically detected from function signatures
|
|
112
|
+
|
|
113
|
+
## Boolean Flags
|
|
114
|
+
|
|
115
|
+
Boolean parameters are automatically converted to flags:
|
|
116
|
+
|
|
117
|
+
```python
|
|
118
|
+
def process(name: str, verbose: bool = False, enabled: bool = True):
|
|
119
|
+
"""Process with flags.
|
|
120
|
+
|
|
121
|
+
Args:
|
|
122
|
+
name: Item name
|
|
123
|
+
verbose: Enable verbose output
|
|
124
|
+
enabled: Whether processing is enabled
|
|
125
|
+
"""
|
|
126
|
+
pass
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
Usage:
|
|
130
|
+
|
|
131
|
+
```bash
|
|
132
|
+
# verbose defaults to False, use --verbose to set True
|
|
133
|
+
python script.py --name test --verbose
|
|
134
|
+
|
|
135
|
+
# enabled defaults to True, use --no-enabled to set False
|
|
136
|
+
python script.py --name test --no-enabled
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
## Docstring Support
|
|
140
|
+
|
|
141
|
+
`autoarg` supports multiple docstring formats:
|
|
142
|
+
|
|
143
|
+
### Google Style
|
|
144
|
+
|
|
145
|
+
```python
|
|
146
|
+
def func(param1: str, param2: int):
|
|
147
|
+
"""Function description.
|
|
148
|
+
|
|
149
|
+
Args:
|
|
150
|
+
param1: Description of param1
|
|
151
|
+
param2: Description of param2
|
|
152
|
+
"""
|
|
153
|
+
pass
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
### NumPy Style
|
|
157
|
+
|
|
158
|
+
```python
|
|
159
|
+
def func(param1: str, param2: int):
|
|
160
|
+
"""Function description.
|
|
161
|
+
|
|
162
|
+
Parameters
|
|
163
|
+
----------
|
|
164
|
+
param1 : str
|
|
165
|
+
Description of param1
|
|
166
|
+
param2 : int
|
|
167
|
+
Description of param2
|
|
168
|
+
"""
|
|
169
|
+
pass
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
### reStructuredText Style
|
|
173
|
+
|
|
174
|
+
```python
|
|
175
|
+
def func(param1: str, param2: int):
|
|
176
|
+
"""Function description.
|
|
177
|
+
|
|
178
|
+
:param param1: Description of param1
|
|
179
|
+
:param param2: Description of param2
|
|
180
|
+
"""
|
|
181
|
+
pass
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
## Advanced Example
|
|
185
|
+
|
|
186
|
+
```python
|
|
187
|
+
from typing import List, Optional
|
|
188
|
+
from aap import autoarg
|
|
189
|
+
|
|
190
|
+
def backup_database(
|
|
191
|
+
host: str,
|
|
192
|
+
database: str,
|
|
193
|
+
output_file: str,
|
|
194
|
+
port: int = 5432,
|
|
195
|
+
username: Optional[str] = None,
|
|
196
|
+
compress: bool = True,
|
|
197
|
+
tables: Optional[List[str]] = None
|
|
198
|
+
):
|
|
199
|
+
"""Backup a PostgreSQL database.
|
|
200
|
+
|
|
201
|
+
Args:
|
|
202
|
+
host: Database host
|
|
203
|
+
database: Database name
|
|
204
|
+
output_file: Output backup file path
|
|
205
|
+
port: Database port
|
|
206
|
+
username: Database username
|
|
207
|
+
compress: Compress the backup file
|
|
208
|
+
tables: Specific tables to backup
|
|
209
|
+
"""
|
|
210
|
+
# Implementation here
|
|
211
|
+
pass
|
|
212
|
+
|
|
213
|
+
if __name__ == "__main__":
|
|
214
|
+
cli = autoarg(backup_database)
|
|
215
|
+
cli()
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
Usage:
|
|
219
|
+
|
|
220
|
+
```bash
|
|
221
|
+
# Basic backup
|
|
222
|
+
python backup.py --host localhost --database mydb --output-file backup.sql
|
|
223
|
+
|
|
224
|
+
# Advanced backup with options
|
|
225
|
+
python backup.py --host db.example.com --database prod \
|
|
226
|
+
--output-file backup.sql --port 3306 --username admin \
|
|
227
|
+
--no-compress --tables users orders products
|
|
228
|
+
```
|
|
229
|
+
|
|
230
|
+
## Type Annotations
|
|
231
|
+
|
|
232
|
+
Type hints are required for proper CLI generation. If a parameter lacks a type annotation, `autoarg` will issue a warning and default to `str` type:
|
|
233
|
+
|
|
234
|
+
```python
|
|
235
|
+
def func(typed_param: int, untyped_param):
|
|
236
|
+
pass
|
|
237
|
+
# Warning: Parameter 'untyped_param' has no type annotation. Defaulting to str type.
|
|
238
|
+
```
|
|
239
|
+
|
|
240
|
+
## Development
|
|
241
|
+
|
|
242
|
+
### Running Tests
|
|
243
|
+
|
|
244
|
+
```bash
|
|
245
|
+
pytest tests/ -v --cov=autoarg --cov-report=term-missing
|
|
246
|
+
```
|
|
247
|
+
|
|
248
|
+
### Building the Package
|
|
249
|
+
|
|
250
|
+
```bash
|
|
251
|
+
python -m build
|
|
252
|
+
```
|
|
253
|
+
|
|
254
|
+
## License
|
|
255
|
+
|
|
256
|
+
MIT License
|
|
257
|
+
|
|
258
|
+
## Contributing
|
|
259
|
+
|
|
260
|
+
Contributions are welcome. Please ensure all tests pass and maintain 100% code coverage for new features.
|
|
261
|
+
|
|
262
|
+
## Generative Artificial Intelligence Disclosure
|
|
263
|
+
|
|
264
|
+
This package was created using Cline and claude-sonnet-4-5 starting from the following prompt:
|
|
265
|
+
|
|
266
|
+
> Create a python package in this directory called aap. Auto arg parse has one functionality. That functionality is to take a callable or a list of callables and return another call, which wraps the input callable and uses python built-in argparse library to receive all input parameters to the call from command line input. Use the python type hints to figure out the type of the input parameters, and use the callable's documentation to figure out descriptions or help messages for the parameters. Throw a warning if a input parameter is not typed. If there are multiple callables passed to aap, create commands for each, with their own parameters parsed.
|
|
267
|
+
>
|
|
268
|
+
> Create a professional concise read me with no emojis.
|
|
269
|
+
>
|
|
270
|
+
> Create tests that use pytest and have a coverage of 100%.
|
|
271
|
+
>
|
|
272
|
+
> Create a pyproject.toml and package for pypi for distribution through pip or uv.
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"""
|
|
2
|
+
aap - Automatic argparse wrapper for Python callables.
|
|
3
|
+
|
|
4
|
+
This package provides functionality to automatically generate command-line
|
|
5
|
+
interfaces from Python functions using their type hints and docstrings.
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
from .core import autoarg
|
|
9
|
+
|
|
10
|
+
__version__ = "0.1.0"
|
|
11
|
+
__all__ = ["autoarg"]
|