Commander
Command
Command decorator
This decorator is used to register a function as a command. It will automatically generate the command line arguments for the function based on the annotations.
Example
Returns:
Name | Type | Description |
---|---|---|
decorator |
Callable
|
The decorated function. |
aliased_method
Aliased Method
Given a name of a command, check the schema and find the real method name because the command might be aliased. The given class will be used to discover any ancestors because the command may actually come from a parent class.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
cls |
Type
|
The class to check the schema for. |
required |
command |
str
|
The command to find the |
required |
Returns:
Name | Type | Description |
---|---|---|
method |
str
|
The true name of the commands method. |
available_formats
Available Formats
Returns:
Type | Description |
---|---|
List[str]
|
A list of available format names. |
available_resources
Available Resources
Returns:
Type | Description |
---|---|
List[str]
|
A list of available resources names. |
extract_args
Extract Args
Extract the cli argument annotations from a function. This will only collect the args of type duplocloud.Arg. This list can now be used to generate an argparse.ArgumentParser object.
get_parser
Get Parser
Parameters:
Name | Type | Description | Default |
---|---|---|---|
args |
List[Arg]
|
A list of Arg objects. |
required |
Returns: An argparse.ArgumentParser object with args from function.
load_format
Load Format
Load a Formatter function from the entry points.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name |
str
|
The name of the format. |
'string'
|
Returns: The class of the format.
load_resource
Load Service
Load a Service class from the entry points.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name |
str
|
The name of the service. |
required |
Returns: The class of the service.