CLI Fundamentals
params-proto automatically generates command-line interfaces from your Python code.
How It Works
When you use @proto.cli, params-proto:
- Inspects your function signature - Reads parameters, types, and defaults
- Extracts documentation - From inline comments and docstrings
- Converts names - Transforms Python naming to CLI conventions (snake_case → kebab-case)
- Generates argparse - Creates CLI parser automatically
- Type converts - Parses and validates CLI arguments
↓ Automatically becomes ↓
Type Display
Parameter types appear in help text:
| Python Type | CLI Display | Example |
|---|---|---|
int | INT | --count INT |
float | FLOAT | --lr FLOAT |
str | STR | --name STR |
bool | (flag) | --verbose |
int | float | VALUE | --threshold VALUE |
str | None | VALUE | --config VALUE |
Literal["a", "b"] | VALUE | --mode VALUE |
Enum | {A,B,C} | --opt {ADAM,SGD} |
List[int] | VALUE | --ids VALUE |
Path | VALUE | --dir VALUE |
Boolean Flags
Boolean parameters become flags:
CLI usage:
Required vs Optional
Optional parameters (with defaults):
Help text:
Required parameters (no defaults):
Help text:
Union and Class Parameters
See Union Types for:
- Union subcommands (choosing between multiple configurations)
- Single class parameters
- Attribute overrides
- Positional selection
Related
- CLI Patterns - Advanced patterns (grouped options, testing, edge cases)
- Naming Conventions - Parameter and class name conversion rules
- Help Generation - Documentation extraction and formatting
Union Types- Union subcommands and optional parameters- Type System - Supported types and conversion
ANSI Formatting- Terminal colors and formatting