Reference
Command
Command(
name: str,
handler: callable,
description: Optional[str] = None,
usage: Optional[str] = None,
options: Optional[List[Option]] = None,
inherit_options: Optional[bool] = False,
arguments: Optional[List[Argument]] = None,
inherit_arguments: Optional[bool] = False,
subcommands: Optional[List[Command]] = None,
)
Parameters:
-
(namestr) –The name of the command.
-
(handlercallable) –The function to execute when the command is called.
-
(descriptionOptional[str], default:None) –The description of the command.
-
(usageOptional[str], default:None) –The usage information for the command. Defaults to "[SUBCOMMANDS][OPTIONS][ARGUMENTS]" if not provided.
-
(optionsOptional[List[Option]], default:None) –The options available for the command.
-
(inherit_optionsOptional[bool], default:False) –Whether to inherit options from parent commands.
-
(argumentsOptional[Argument], default:None) –The arguments available for the command.
-
(inherit_argumentsOptional[bool], default:False) –Whether to inherit arguments from parent commands.
-
(subcommandsOptional[List[Command]], default:None) –The subcommands available for the command.
Methods:
-
add_argument–Add an argument to the command.
-
add_arguments–Add multiple arguments to the command.
-
add_option–Add an option to the command.
-
add_options–Add multiple options to the command.
-
add_subcommand–Add a subcommand to the command.
-
add_subcommands–Add multiple subcommands to the command.
-
execute– -
find_subcommand–Find a subcommand by name.
-
flag_to_option–Get an option by flag.
Attributes:
-
all_argument_names(List[str]) –Gather all argument names available to the command.
-
all_arguments(List[Argument]) –Gather all arguments available to the command.
-
all_option_flags(List[str]) –Gather all option flags available to the command.
-
all_option_long_names(List[str]) –Gather all long option names available to the command.
-
all_option_names(List[str]) –Gather all option names available to the command.
-
all_option_short_names(List[str]) –Gather all short option names available to the command.
-
all_options(List[Option]) –Gather all options available to the command.
-
all_subcommand_names(List[str]) –Gather all subcommand names available to the command.
-
arguments– -
description– -
handler– -
inherit_arguments– -
inherit_options– -
inherited_arguments(List[Argument]) –Gather arguments inherited from parent commands if inheritance is enabled.
-
inherited_options(List[Option]) –Gather options inherited from parent commands if inheritance is enabled.
-
name– -
options– -
subcommands– -
usage–
Source code in saiuncli/command.py
all_argument_names
property
Gather all argument names available to the command.
all_option_flags
property
Gather all option flags available to the command.
all_option_long_names
property
Gather all long option names available to the command.
all_option_names
property
Gather all option names available to the command.
all_option_short_names
property
Gather all short option names available to the command.
all_subcommand_names
property
Gather all subcommand names available to the command.
inherited_arguments
property
inherited_arguments: List[Argument]
Gather arguments inherited from parent commands if inheritance is enabled.
inherited_options
property
inherited_options: List[Option]
Gather options inherited from parent commands if inheritance is enabled.
add_argument
add_argument(argument: Argument)
add_arguments
add_arguments(arguments: List[Argument])
add_option
add_option(option: Option)
add_options
add_options(options: List[Option])
add_subcommands
add_subcommands(subcommands: List[Command])
Add multiple subcommands to the command.
Source code in saiuncli/command.py
execute
find_subcommand
find_subcommand(name: str) -> Optional[Command]
flag_to_option
flag_to_option(flag: str) -> Optional[Option]