Skip to content

Commit 6948c9c

Browse files
committed
Added md instead of htmls into the llms.txt
1 parent 47c9cbb commit 6948c9c

2 files changed

Lines changed: 105 additions & 13 deletions

File tree

CLAUDE.md

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,98 @@ uv run ruff format # apply formatting
1616
uv run mypy # type checking
1717
```
1818

19+
## Examples
20+
21+
### Minimal parser
22+
23+
```python
24+
import argclass
25+
26+
class CLI(argclass.Parser):
27+
host: str = "localhost" # --host (default: localhost)
28+
port: int = 8080 # --port (default: 8080)
29+
verbose: bool = False # --verbose flag (store_true)
30+
31+
parser = CLI()
32+
parser.parse_args()
33+
```
34+
35+
### Optional, list, and literal types
36+
37+
```python
38+
from typing import Optional, Literal
39+
import argclass
40+
41+
class CLI(argclass.Parser):
42+
name: Optional[str] = None # --name (optional)
43+
tags: list[str] = argclass.Argument( # --tags a b c
44+
nargs=argclass.Nargs.ONE_OR_MORE,
45+
)
46+
mode: Literal["fast", "slow"] = "fast" # --mode {fast,slow}
47+
```
48+
49+
### Argument groups
50+
51+
```python
52+
import argclass
53+
54+
class Database(argclass.Group):
55+
host: str = "localhost"
56+
port: int = 5432
57+
58+
class CLI(argclass.Parser):
59+
debug: bool = False
60+
db: Database = Database(title="Database options")
61+
62+
parser = CLI()
63+
parser.parse_args()
64+
print(parser.db.host, parser.db.port)
65+
```
66+
67+
### Subcommands
68+
69+
```python
70+
import argclass
71+
72+
class Serve(argclass.Parser):
73+
port: int = 8080
74+
75+
class Deploy(argclass.Parser):
76+
target: str = "production"
77+
78+
class CLI(argclass.Parser):
79+
serve = Serve()
80+
deploy = Deploy()
81+
```
82+
83+
### Environment variables and secrets
84+
85+
```python
86+
import argclass
87+
88+
class CLI(argclass.Parser):
89+
db_url: str = argclass.Argument(env_var="DATABASE_URL")
90+
api_key: str = argclass.Secret() # masked in repr/logs
91+
92+
# auto_env_var_prefix generates env vars from arg names
93+
parser = CLI(auto_env_var_prefix="APP_")
94+
parser.parse_args()
95+
parser.sanitize_env(only_secrets=True)
96+
```
97+
98+
### Testing parsers
99+
100+
```python
101+
class CLI(argclass.Parser):
102+
debug: bool = False
103+
db: Database = Database(title="Database options")
104+
105+
parser = CLI()
106+
parser.parse_args(["--debug", "--db-host=127.0.0.1", "--db-port", "9876"])
107+
assert parser.debug is True
108+
assert parser.db.host == "127.0.0.1"
109+
```
110+
19111
## Architecture
20112

21113
Metaclass-driven: `Meta` metaclass in `parser.py` processes annotations at class definition time, creating `__arguments__`, `__argument_groups__`, `__subparsers__`.

docs/llm.txt

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,20 @@ Key API classes: `Parser` (main entry point), `Argument`, `Group`, `Secret`, `IN
88

99
## Docs
1010

11-
- [Quick Start](https://docs.argclass.com/quickstart.html): 5-minute overview of essential concepts
12-
- [Tutorial](https://docs.argclass.com/tutorial.html): 30-minute guide building a complete CLI application
13-
- [Arguments](https://docs.argclass.com/arguments.html): Typed arguments, defaults, nargs, enums, boolean flags
14-
- [Groups](https://docs.argclass.com/groups.html): Reusable argument groups with prefix support
15-
- [Subparsers](https://docs.argclass.com/subparsers.html): Hierarchical subcommands and nested parsers
16-
- [Config Files](https://docs.argclass.com/config-files.html): INI, JSON, and TOML configuration file support
17-
- [Environment Variables](https://docs.argclass.com/environment.html): Automatic env var binding with prefixes
18-
- [Secrets](https://docs.argclass.com/secrets.html): Secret masking to prevent accidental exposure in logs
11+
- [Quick Start](https://docs.argclass.com/_sources/quickstart.md.txt): 5-minute overview of essential concepts
12+
- [Tutorial](https://docs.argclass.com/_sources/tutorial.md.txt): 30-minute guide building a complete CLI application
13+
- [Arguments](https://docs.argclass.com/_sources/arguments.md.txt): Typed arguments, defaults, nargs, enums, boolean flags
14+
- [Groups](https://docs.argclass.com/_sources/groups.md.txt): Reusable argument groups with prefix support
15+
- [Subparsers](https://docs.argclass.com/_sources/subparsers.md.txt): Hierarchical subcommands and nested parsers
16+
- [Config Files](https://docs.argclass.com/_sources/config-files.md.txt): INI, JSON, and TOML configuration file support
17+
- [Environment Variables](https://docs.argclass.com/_sources/environment.md.txt): Automatic env var binding with prefixes
18+
- [Secrets](https://docs.argclass.com/_sources/secrets.md.txt): Secret masking to prevent accidental exposure in logs
1919
- [API Reference](https://docs.argclass.com/api.html): Full API documentation with all classes and functions
2020

2121
## Optional
2222

23-
- [Examples Gallery](https://docs.argclass.com/examples.html): Ready-to-use patterns from simple CLIs to multi-command tools
24-
- [Error Handling](https://docs.argclass.com/errors.html): Error types and handling strategies
25-
- [Common Pitfalls](https://docs.argclass.com/pitfalls.html): Frequent mistakes and how to avoid them
26-
- [Integrations](https://docs.argclass.com/integrations.html): Using argclass with other tools
27-
- [Security](https://docs.argclass.com/security.html): Security policy and best practices
23+
- [Examples Gallery](https://docs.argclass.com/_sources/examples.md.txt): Ready-to-use patterns from simple CLIs to multi-command tools
24+
- [Error Handling](https://docs.argclass.com/_sources/errors.md.txt): Error types and handling strategies
25+
- [Common Pitfalls](https://docs.argclass.com/_sources/pitfalls.md.txt): Frequent mistakes and how to avoid them
26+
- [Integrations](https://docs.argclass.com/_sources/integrations.md.txt): Using argclass with other tools
27+
- [Security](https://docs.argclass.com/_sources/security.md.txt): Security policy and best practices

0 commit comments

Comments
 (0)