argparse
add_model(parser, model)
¶
Add a pydantic model to an argparse ArgumentParser.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
parser |
ArgumentParser
|
The ArgumentParser instance. |
required |
model |
type[BaseModel]
|
The pydantic model declaring the cli options. |
required |
Source code in m/cli/engine/argparse.py
command(*, help, model, name=None)
¶
Apply a decorator to the run
function to make it into a command.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name |
str | None
|
The command name. |
None
|
help |
str
|
A short description of the command. |
required |
model |
type[BaseModel]
|
A pydantic model to describe the cli arguments. |
required |
Returns:
Type | Description |
---|---|
partial[partial[int]]
|
A transformed run function aware of the arguments model. |