pyTooling.CLIAbstraction.Flag

Flag arguments represent simple boolean values by being present or absent.

See also

  • For flags with different pattern based on the boolean value itself.
    BooleanFlag

  • For flags with a value.
    ValuedFlag

  • For flags that have an optional value.
    NamedOptionalValuedFlag

Classes

  • FlagArgument: Base-class for all Flag classes, which represents a simple flag argument like -v or --verbose.

  • ShortFlag: Represents a Flag argument with a single dash.

  • LongFlag: Represents a Flag argument with a double dash.

  • WindowsFlag: Represents a Flag argument with a single slash.


Classes

class pyTooling.CLIAbstraction.Flag.FlagArgument(*args: Any, **kwargs: Any)[source]

Base-class for all Flag classes, which represents a simple flag argument like -v or --verbose.

A simple flag is a single value (absent/present or off/on) with no additional data (value).

Inheritance

Inheritance diagram of FlagArgument

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.Flag.ShortFlag(*args: Any, **kwargs: Any)[source]

Represents a Flag argument with a single dash.

Example:

  • -optimize

Inheritance

Inheritance diagram of ShortFlag

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

This method is called when a class is derived.

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

  • name – Name of the argument.

  • 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.Flag.LongFlag(*args: Any, **kwargs: Any)[source]

Represents a Flag argument with a double dash.

Example:

  • --optimize

Inheritance

Inheritance diagram of LongFlag

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

This method is called when a class is derived.

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

  • name – Name of the argument.

  • 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.Flag.WindowsFlag(*args: Any, **kwargs: Any)[source]

Represents a Flag argument with a single slash.

Example:

  • /optimize

Inheritance

Inheritance diagram of WindowsFlag

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

This method is called when a class is derived.

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

  • name – Name of the argument.

  • 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.