duho 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.
- duho-0.1.0/.gitignore +139 -0
- duho-0.1.0/CHANGELOG.md +65 -0
- duho-0.1.0/CONTRIBUTING.md +77 -0
- duho-0.1.0/LICENSE +21 -0
- duho-0.1.0/PKG-INFO +525 -0
- duho-0.1.0/README.md +463 -0
- duho-0.1.0/RELEASENOTES.md +92 -0
- duho-0.1.0/docs/api/args.md +3 -0
- duho-0.1.0/docs/api/completion.md +3 -0
- duho-0.1.0/docs/api/logging.md +3 -0
- duho-0.1.0/docs/api/presets.md +3 -0
- duho-0.1.0/docs/api/reference.md +13 -0
- duho-0.1.0/docs/changelog.md +3 -0
- duho-0.1.0/docs/guide/arguments.md +161 -0
- duho-0.1.0/docs/guide/completion.md +62 -0
- duho-0.1.0/docs/guide/config.md +93 -0
- duho-0.1.0/docs/guide/logging.md +88 -0
- duho-0.1.0/docs/guide/running.md +147 -0
- duho-0.1.0/docs/guide/types.md +124 -0
- duho-0.1.0/docs/index.md +92 -0
- duho-0.1.0/examples/buildutils.py +116 -0
- duho-0.1.0/examples/dotagents.py +61 -0
- duho-0.1.0/mkdocs.yml +62 -0
- duho-0.1.0/pyproject.toml +51 -0
- duho-0.1.0/src/duho/__init__.py +69 -0
- duho-0.1.0/src/duho/_compat.py +27 -0
- duho-0.1.0/src/duho/_introspect.py +182 -0
- duho-0.1.0/src/duho/args.py +937 -0
- duho-0.1.0/src/duho/completion.py +364 -0
- duho-0.1.0/src/duho/logging.py +165 -0
- duho-0.1.0/src/duho/parsers.py +117 -0
- duho-0.1.0/src/duho/presets.py +66 -0
- duho-0.1.0/src/duho/py.typed +0 -0
- duho-0.1.0/tests/test_args.py +721 -0
- duho-0.1.0/tests/test_completion.py +124 -0
- duho-0.1.0/tests/test_config.py +218 -0
- duho-0.1.0/tests/test_examples.py +55 -0
- duho-0.1.0/tests/test_features.py +362 -0
- duho-0.1.0/tests/test_integration.py +190 -0
- duho-0.1.0/tests/test_logging.py +225 -0
- duho-0.1.0/tests/test_parse.py +68 -0
duho-0.1.0/.gitignore
ADDED
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
# Byte-compiled / optimized / DLL files
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[cod]
|
|
4
|
+
*$py.class
|
|
5
|
+
|
|
6
|
+
# C extensions
|
|
7
|
+
*.so
|
|
8
|
+
|
|
9
|
+
# Distribution / packaging
|
|
10
|
+
.Python
|
|
11
|
+
build/
|
|
12
|
+
develop-eggs/
|
|
13
|
+
dist/
|
|
14
|
+
downloads/
|
|
15
|
+
eggs/
|
|
16
|
+
.eggs/
|
|
17
|
+
lib/
|
|
18
|
+
lib64/
|
|
19
|
+
parts/
|
|
20
|
+
sdist/
|
|
21
|
+
var/
|
|
22
|
+
wheels/
|
|
23
|
+
pip-wheel-metadata/
|
|
24
|
+
share/python-wheels/
|
|
25
|
+
*.egg-info/
|
|
26
|
+
.installed.cfg
|
|
27
|
+
*.egg
|
|
28
|
+
MANIFEST
|
|
29
|
+
|
|
30
|
+
# PyInstaller
|
|
31
|
+
*.manifest
|
|
32
|
+
*.spec
|
|
33
|
+
|
|
34
|
+
# Unit test / coverage reports
|
|
35
|
+
htmlcov/
|
|
36
|
+
.tox/
|
|
37
|
+
.nox/
|
|
38
|
+
.coverage
|
|
39
|
+
.coverage.*
|
|
40
|
+
.cache
|
|
41
|
+
nosetests.xml
|
|
42
|
+
coverage.xml
|
|
43
|
+
*.cover
|
|
44
|
+
*.py,cover
|
|
45
|
+
.hypothesis/
|
|
46
|
+
.pytest_cache/
|
|
47
|
+
|
|
48
|
+
# Translations
|
|
49
|
+
*.mo
|
|
50
|
+
*.pot
|
|
51
|
+
|
|
52
|
+
# Django stuff:
|
|
53
|
+
*.log
|
|
54
|
+
local_settings.py
|
|
55
|
+
db.sqlite3
|
|
56
|
+
db.sqlite3-journal
|
|
57
|
+
|
|
58
|
+
# Flask stuff:
|
|
59
|
+
instance/
|
|
60
|
+
.webassets-cache
|
|
61
|
+
|
|
62
|
+
# Scrapy stuff:
|
|
63
|
+
.scrapy
|
|
64
|
+
|
|
65
|
+
# Sphinx documentation
|
|
66
|
+
docs/_build/
|
|
67
|
+
|
|
68
|
+
# PyBuilder
|
|
69
|
+
target/
|
|
70
|
+
|
|
71
|
+
# Jupyter Notebook
|
|
72
|
+
.ipynb_checkpoints
|
|
73
|
+
|
|
74
|
+
# IPython
|
|
75
|
+
profile_default/
|
|
76
|
+
ipython_config.py
|
|
77
|
+
|
|
78
|
+
# pyenv
|
|
79
|
+
.python-version
|
|
80
|
+
|
|
81
|
+
# pipenv
|
|
82
|
+
Pipfile.lock
|
|
83
|
+
|
|
84
|
+
# PEP 582
|
|
85
|
+
__pypackages__/
|
|
86
|
+
|
|
87
|
+
# Celery stuff
|
|
88
|
+
celerybeat-schedule
|
|
89
|
+
celerybeat.pid
|
|
90
|
+
|
|
91
|
+
# SageMath parsed files
|
|
92
|
+
*.sage.py
|
|
93
|
+
|
|
94
|
+
# Environments
|
|
95
|
+
.env
|
|
96
|
+
.venv
|
|
97
|
+
env/
|
|
98
|
+
venv/
|
|
99
|
+
ENV/
|
|
100
|
+
env.bak/
|
|
101
|
+
venv.bak/
|
|
102
|
+
|
|
103
|
+
# Spyder project settings
|
|
104
|
+
.spyderproject
|
|
105
|
+
.spyproject
|
|
106
|
+
|
|
107
|
+
# Rope project settings
|
|
108
|
+
.ropeproject
|
|
109
|
+
|
|
110
|
+
# mkdocs documentation
|
|
111
|
+
/site
|
|
112
|
+
|
|
113
|
+
# mypy
|
|
114
|
+
.mypy_cache/
|
|
115
|
+
.dmypy.json
|
|
116
|
+
dmypy.json
|
|
117
|
+
|
|
118
|
+
# Pyre type checker
|
|
119
|
+
.pyre/
|
|
120
|
+
|
|
121
|
+
# IDE
|
|
122
|
+
.vscode/
|
|
123
|
+
.idea/
|
|
124
|
+
*.swp
|
|
125
|
+
*.swo
|
|
126
|
+
*~
|
|
127
|
+
|
|
128
|
+
# OS
|
|
129
|
+
.DS_Store
|
|
130
|
+
Thumbs.db
|
|
131
|
+
|
|
132
|
+
# Project-specific
|
|
133
|
+
.agents/
|
|
134
|
+
.claude/
|
|
135
|
+
CLAUDE*
|
|
136
|
+
AGENTS.md
|
|
137
|
+
|
|
138
|
+
# Benchmark run outputs (local, machine-specific)
|
|
139
|
+
benchmarks/results/
|
duho-0.1.0/CHANGELOG.md
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this project will be documented in this file.
|
|
4
|
+
|
|
5
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
|
6
|
+
and this project adheres to [Semantic Versioning](https://semver.org/).
|
|
7
|
+
|
|
8
|
+
## [Unreleased]
|
|
9
|
+
|
|
10
|
+
## [0.1.0] - 2026-07-14
|
|
11
|
+
|
|
12
|
+
Initial release.
|
|
13
|
+
|
|
14
|
+
### Added
|
|
15
|
+
|
|
16
|
+
- **Declarative `Args` classes** — define a CLI by annotating class fields. The
|
|
17
|
+
field's docstring becomes its help text and a following tuple literal declares
|
|
18
|
+
its flags (`("--name", "-n")`); with no tuple, the flag is derived from the
|
|
19
|
+
field name (`dry_run` → `--dry-run`).
|
|
20
|
+
- **Type-driven conversion** from annotations: `str`/`int`/`float`/`bool`,
|
|
21
|
+
`typing.Literal` (→ `choices`), `enum.Enum` (members matched by name),
|
|
22
|
+
`list[T]` (repeated or space-separated), `Optional[T]`, and `Union[A, B]`
|
|
23
|
+
(including PEP 604 `A | B` on 3.10+). Enums inside a `Union`/`Optional` are
|
|
24
|
+
matched by member name, consistently with bare enum fields.
|
|
25
|
+
- **Positional arguments** — a flag tuple with no leading dash (`("source",)`);
|
|
26
|
+
a positional with a default becomes optional (`nargs="?"`).
|
|
27
|
+
- **Full argparse passthrough** via `Arg[T, NS(...)]` — `action`, `nargs`,
|
|
28
|
+
`const`, `metavar`, `dest`, `choices`, and any other `add_argument` keyword,
|
|
29
|
+
plus `NS(conflicts="group")` for mutually exclusive groups.
|
|
30
|
+
- **Argument helpers**: `Count()`, `Append()`, `Const()`, `Choice()`, `Extend()`,
|
|
31
|
+
and the `UpdateAction` action.
|
|
32
|
+
- **Entry points**: `duho.parser(cls)` builds a parser; `duho.parse(spec, argv)`
|
|
33
|
+
builds and parses in one call — passing an *instance* layers CLI overrides on
|
|
34
|
+
top of its field values (CLI > instance > class default) and returns a new
|
|
35
|
+
instance without mutating the original.
|
|
36
|
+
- **Command dispatch**: `duho.main(cls, argv=None)` builds, parses, sets up
|
|
37
|
+
logging, and calls the selected instance's `__run__()`. `_subcommands_` builds
|
|
38
|
+
nested subparser trees automatically and dispatches to the deepest selected
|
|
39
|
+
class.
|
|
40
|
+
- **Layered defaults**: per-field environment variables via `NS(env="VAR")` and
|
|
41
|
+
TOML config files via `_config_` / `config=`, with the precedence ladder
|
|
42
|
+
CLI > env > config > class default. Any layer supplying a value also
|
|
43
|
+
un-requires that field. `duho.value_sources(parsed)` reports which layer won
|
|
44
|
+
for each field.
|
|
45
|
+
- **`--version`**: set `_version_` to a string, or to `duho.AUTO` to resolve it
|
|
46
|
+
from installed package metadata (`_distribution_` overrides the distribution
|
|
47
|
+
name). When the distribution isn't installed, no `--version` flag is added
|
|
48
|
+
rather than printing a bogus version.
|
|
49
|
+
- **Shell completion**: opt in with `_completion_ = True` to add
|
|
50
|
+
`--print-completion {bash,zsh,fish}`, or call `duho.print_completion()`.
|
|
51
|
+
Scripts are generated statically — no runtime dependency and no re-invoking
|
|
52
|
+
your program on every keypress.
|
|
53
|
+
- **`LoggingArgs`** preset — `-v`/`-q` counted verbosity (offsetting, clamped at
|
|
54
|
+
each end of the scale), `--loglevel` for global or per-module levels, colored
|
|
55
|
+
stderr output (optional `colorama`), and a `TRACE` level.
|
|
56
|
+
- Type hints ship with the package (`py.typed`).
|
|
57
|
+
|
|
58
|
+
### Notes
|
|
59
|
+
|
|
60
|
+
- Zero required runtime dependencies. Optional extras: `colorama` (colored
|
|
61
|
+
logging) and `config` (TOML on Python 3.9/3.10, where `tomllib` isn't stdlib).
|
|
62
|
+
- Supports Python 3.9 through 3.13.
|
|
63
|
+
|
|
64
|
+
[Unreleased]: https://github.com/jose-pr/duho/compare/v0.1.0...HEAD
|
|
65
|
+
[0.1.0]: https://github.com/jose-pr/duho/releases/tag/v0.1.0
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
# Contributing to Duho
|
|
2
|
+
|
|
3
|
+
Thanks for your interest in contributing! Here's how to get started.
|
|
4
|
+
|
|
5
|
+
## Development Setup
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
# Clone the repo
|
|
9
|
+
git clone https://github.com/jose-pr/duho.git
|
|
10
|
+
cd duho
|
|
11
|
+
|
|
12
|
+
# Create a virtual environment
|
|
13
|
+
python -m venv venv
|
|
14
|
+
source venv/bin/activate # On Windows: venv\Scripts\activate
|
|
15
|
+
|
|
16
|
+
# Install in development mode with test dependencies
|
|
17
|
+
pip install -e ".[dev]"
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## Running Tests
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
pytest
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
Run with coverage:
|
|
27
|
+
|
|
28
|
+
```bash
|
|
29
|
+
pytest --cov=src/duho tests/
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## Running Benchmarks
|
|
33
|
+
|
|
34
|
+
```bash
|
|
35
|
+
python -m benchmarks.bench_parsing
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
## Code Style
|
|
39
|
+
|
|
40
|
+
- Follow PEP 8
|
|
41
|
+
- Use type hints
|
|
42
|
+
- Keep functions focused and well-named
|
|
43
|
+
|
|
44
|
+
## Commit Guidelines
|
|
45
|
+
|
|
46
|
+
Follow the format: `type: description`
|
|
47
|
+
|
|
48
|
+
- `feat:` New feature
|
|
49
|
+
- `fix:` Bug fix
|
|
50
|
+
- `docs:` Documentation
|
|
51
|
+
- `test:` Test additions/improvements
|
|
52
|
+
- `chore:` Build, CI, or tooling changes
|
|
53
|
+
|
|
54
|
+
Examples:
|
|
55
|
+
- `feat: add shell completion support`
|
|
56
|
+
- `fix: handle union types with None correctly`
|
|
57
|
+
- `docs: add subcommand examples`
|
|
58
|
+
|
|
59
|
+
## Pull Request Process
|
|
60
|
+
|
|
61
|
+
1. Create a feature branch: `git checkout -b feature/my-feature`
|
|
62
|
+
2. Make your changes and add tests
|
|
63
|
+
3. Run `pytest` to ensure all tests pass
|
|
64
|
+
4. Commit with a clear message (see guidelines above)
|
|
65
|
+
5. Push to your fork and open a pull request
|
|
66
|
+
|
|
67
|
+
## Reporting Issues
|
|
68
|
+
|
|
69
|
+
When reporting bugs, please include:
|
|
70
|
+
- Python version
|
|
71
|
+
- Duho version
|
|
72
|
+
- Minimal code example that reproduces the issue
|
|
73
|
+
- Expected vs. actual behavior
|
|
74
|
+
|
|
75
|
+
## Questions?
|
|
76
|
+
|
|
77
|
+
Open a discussion or issue on GitHub!
|
duho-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Jose A.
|
|
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.
|