powercli.command¶
The heart of PowerCLI - the command class.
Module Contents¶
Classes¶
API¶
- class powercli.command.Example¶
An example describing the usage of a command.
- args: collections.abc.Collection[str]¶
None
The arguments of the command.
This should not contain the name of any parent commands or the command itself.
- class powercli.command.Command¶
A command which might contains arguments and subcommands.
Parameters
name- Sets the name of the command.Defaults to the first argument provided in the command-line (
sys.argv[0]).aliases- A set of aliases this command can be invoked with as well.Note
This only applies for subcommands.
hidden_aliases- Same asaliasesbut not shown in help messages.description- A short description of the command.long_description- A concise description of the command.epilog- Additional text displayed at the bottom.prefix_short- The prefix used to specify flags by their short name.Most command-line programs use dashes (
-) for flags. This is the default and can be explicitly specified as shown below.from powercli import Command Command( # ... prefix_short="-", prefix_long="--", )
On Windows, command-line programs commonly use slashes (
/) for flags. Each flag needs to be prefixed separately which means flags with both short and long names cannot be registered.from powercli import Command Command( # ... prefix_long="/", )
prefix_long- The prefix used to specify flags by their long name.See also
category- An optional category used for grouping commands.deprecation- Whether this command is deprecated.file- The file used for commands or arguments that display text.add_common_flags- Addsh,help,listandversionflags.This only has an effect when a prefix is defined for the command.
add_common_subcommands- Addshelp,list,versionsubcommands.
- aliases: set[str]¶
‘Factory(…)’
A set of aliases this command can be invoked with if it’s a subcommand.
‘Factory(…)’
A set of hidden aliases this command can be invoked with if it’s a subcommand.
- category: powercli.category.Category | None¶
None
The optional category of this command.
- deprecation: powercli.deprecation.Deprecation | bool | None¶
None
Whether this command is deprecated.
- examples: collections.abc.Collection[powercli.command.Example]¶
‘Factory(…)’
A collection of examples describing the usage of this command.
- property parent: powercli.command.Command[FV, PV] | None¶
Returns the parent command.
- parents() collections.abc.Generator[powercli.command.Command[FV, PV], None, None]¶
Yields each parent command.
- names() collections.abc.Generator[str, None, None]¶
Yields all names this command can be invoked with.
- add_arg(arg: powercli.args.Argument, /) powercli.command.Command[FV, PV]¶
Registers an argument to the command.
- add_args(args: collections.abc.Iterable[powercli.args.Argument], /) powercli.command.Command[FV, PV]¶
Registers multiple arguments to the command.
- add_subcommand(cmd: powercli.command.Command[FV, PV], /) powercli.command.Command[FV, PV]¶
Registers a subcommand to the command.
- flag(*args: Any, **kwargs: Any) powercli.command.Command[FV, PV]¶
Creates and registers a flag to the command.
- pos(*args: Any, **kwargs: Any) powercli.command.Command[FV, PV]¶
Creates and registers a positional to the command.
- vpos(*args: Any, **kwargs: Any) powercli.command.Command[FV, PV]¶
Creates and registers a variadic positional to the command.
- parse_args(args: list[str] | None = None) powercli.parser.ParsedCommand[FV, PV]¶
Parses arguments from
args, or, ifNonefromargv.