ExternalCommand

class ExternalCommand

An external CLI command that may be invoked by the command line argument parser.

Implementations must override both help and execute as they are otherwise abstract!

Members defined in ExternalCommand (6 members)

aliases

R

Additional aliases to parse as this command.

description

R

Brief description of this command that will be displayed in help of its parent.

name

R

The name of this command that will also be displayed in help.

__init__

Construct new ExternalCommand with the given metadata.

execute

Execute this command.

help

Print help for this command or its subcommand.

Attributes

property aliases: Sequence[str]

Additional aliases to parse as this command.

Note that duplicate aliases are hard errors, and will terminate the program.

property description: str

Brief description of this command that will be displayed in help of its parent.

By default, only the first paragraph will be displayed. As this command must print verbose help on its own, anything after will never be displayed.

property name: str

The name of this command that will also be displayed in help.

Note that duplicate names are hard errors, and will terminate the program.

Methods

__init__(name: str, description: str, aliases: Sequence[str] = ()) None

Construct new ExternalCommand with the given metadata.

execute(arguments: list[str], ctx: syside.cli.ExtContext) int

Execute this command.

The argument list contains all arguments after reaching this subcommand. For example, syside rule --all will contain "--all" as the only argument if rule was an external command.

Implementations must return an exit code, otherwise the exact behaviour is up to them.

ctx contains additional details of this argument parse.

help(arguments: list[str], ctx: syside.cli.ExtContext) str

Print help for this command or its subcommand.

The argument list contains all arguments after reaching this subcommand. For example, syside help rule list will contain "list" as the only argument if rule was an external command.

To match the behaviour of help command, all arguments should be further subcommands only. Implementations may assume that verbose help was requested.

ctx contains additional details of this argument parse. Note that the help segment will not appear in ctx.path.

Used in