pyTooling.CLIAbstraction.Command

This module implements command arguments. Usually, commands are mutually exclusive and the first argument in a list of arguments to a program.

While commands can or cannot have prefix characters, they shouldn’t be confused with flag arguments or string arguments.

Example:

  • prog command -arg1 --argument2

See also

Classes


Classes

class pyTooling.CLIAbstraction.Command.CommandArgument(*args: Any, **kwargs: Any)[source]

Represents a command argument.

It is usually used to select a sub parser in a CLI argument parser or to hand over all following parameters to a separate tool. An example for a command is ‘checkout’ in git.exe checkout, which calls git-checkout.exe.

Example:

  • command

Inheritance

Inheritance diagram of CommandArgument

Parameters:
static __new__(cls, *args, **kwargs)[source]
Parameters:
AsArgument()

Convert this argument instance to a string representation with proper escaping using the matching pattern based on the internal name.

Return type:

Union[str, Iterable[str]]

Returns:

Formatted argument.

Raises:

ValueError – If internal name is None.

property Name: str

Get the internal name.

Returns:

Internal name.

classmethod __init_subclass__(*args, name=None, pattern='{0}', **kwargs)

This method is called when a class is derived.

Parameters:
  • args (Any) – Any positional arguments.

  • name (Optional[str]) – Name of the argument.

  • pattern (str) – This pattern is used to format an argument.

  • kwargs (Any) – Any keyword argument.

__repr__()

Return a string representation of this argument instance.

Return type:

str

Returns:

Argument formatted and enclosed in double quotes.

__str__()

Return a string representation of this argument instance.

Return type:

str

Returns:

Argument formatted and enclosed in double quotes.

class pyTooling.CLIAbstraction.Command.ShortCommand(*args: Any, **kwargs: Any)[source]

Represents a command name with a single dash.

Example:

  • -command

Inheritance

Inheritance diagram of ShortCommand

Parameters:
classmethod __init_subclass__(*args, pattern='-{0}', **kwargs)[source]

This method is called when a class is derived.

Parameters:
  • args (Any) – Any positional arguments.

  • pattern (str) – This pattern is used to format an argument.

  • kwargs (Any) – Any keyword argument.

static __new__(cls, *args, **kwargs)[source]
Parameters:
AsArgument()

Convert this argument instance to a string representation with proper escaping using the matching pattern based on the internal name.

Return type:

Union[str, Iterable[str]]

Returns:

Formatted argument.

Raises:

ValueError – If internal name is None.

property Name: str

Get the internal name.

Returns:

Internal name.

__repr__()

Return a string representation of this argument instance.

Return type:

str

Returns:

Argument formatted and enclosed in double quotes.

__str__()

Return a string representation of this argument instance.

Return type:

str

Returns:

Argument formatted and enclosed in double quotes.

class pyTooling.CLIAbstraction.Command.LongCommand(*args: Any, **kwargs: Any)[source]

Represents a command name with a double dash.

Example:

  • --command

Inheritance

Inheritance diagram of LongCommand

Parameters:
classmethod __init_subclass__(*args, pattern='--{0}', **kwargs)[source]

This method is called when a class is derived.

Parameters:
  • args (Any) – Any positional arguments.

  • pattern (str) – This pattern is used to format an argument.

  • kwargs (Any) – Any keyword argument.

static __new__(cls, *args, **kwargs)[source]
Parameters:
AsArgument()

Convert this argument instance to a string representation with proper escaping using the matching pattern based on the internal name.

Return type:

Union[str, Iterable[str]]

Returns:

Formatted argument.

Raises:

ValueError – If internal name is None.

property Name: str

Get the internal name.

Returns:

Internal name.

__repr__()

Return a string representation of this argument instance.

Return type:

str

Returns:

Argument formatted and enclosed in double quotes.

__str__()

Return a string representation of this argument instance.

Return type:

str

Returns:

Argument formatted and enclosed in double quotes.

class pyTooling.CLIAbstraction.Command.WindowsCommand(*args: Any, **kwargs: Any)[source]

Represents a command name with a single slash.

Example:

  • /command

Inheritance

Inheritance diagram of WindowsCommand

Parameters:
classmethod __init_subclass__(*args, pattern='/{0}', **kwargs)[source]

This method is called when a class is derived.

Parameters:
  • args (Any) – Any positional arguments.

  • pattern (str) – This pattern is used to format an argument.

  • kwargs (Any) – Any keyword argument.

static __new__(cls, *args, **kwargs)[source]
Parameters:
AsArgument()

Convert this argument instance to a string representation with proper escaping using the matching pattern based on the internal name.

Return type:

Union[str, Iterable[str]]

Returns:

Formatted argument.

Raises:

ValueError – If internal name is None.

property Name: str

Get the internal name.

Returns:

Internal name.

__repr__()

Return a string representation of this argument instance.

Return type:

str

Returns:

Argument formatted and enclosed in double quotes.

__str__()

Return a string representation of this argument instance.

Return type:

str

Returns:

Argument formatted and enclosed in double quotes.