pyTooling.CLIAbstraction.BooleanFlag

Boolean flags are arguments with a name and different pattern for a positive (True) and negative (False) value.

See also

  • For simple flags.
    Flag

  • For flags with a value.
    ValuedFlag

  • For flags that have an optional value.
    NamedOptionalValuedFlag

Classes


Classes

class pyTooling.CLIAbstraction.BooleanFlag.BooleanFlag(value)[source]

Class and base-class for all BooleanFlag classes, which represents a flag argument with different pattern for an enabled/positive (True) or disabled/negative (False) state.

When deriving a subclass from an abstract BooleanFlag class, the parameters pattern and falsePattern are expected.

Example:

  • True: with-checks

  • False: without-checks

Inheritance

Inheritance diagram of BooleanFlag

Parameters:
classmethod __init_subclass__(*args, name=None, pattern='with-{0}', falsePattern='without-{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 when the value is True.

  • falsePattern (str) – This pattern is used to format an argument when the value is False.

  • kwargs (Any) – Any keyword argument.

  • name (str | None)

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

Initializes a BooleanFlag instance.

Parameters:

value (bool) – Initial value set for this argument instance.

Return type:

None

AsArgument()[source]

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

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.

property Value: ValueT

Get the internal value.

Returns:

Internal value.

__class_getitem__()

Parameterizes a generic class.

At least, parameterizing a generic class is the main thing this method does. For example, for some generic class Foo, this is called when we do Foo[int] - there, with cls=Foo and params=int.

However, note that this method is also called when defining generic classes in the first place with class Foo[T]: ….

__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.BooleanFlag.ShortBooleanFlag(value)[source]

Represents a BooleanFlag with a single dash.

Example:

  • True: -with-checks

  • False: -without-checks

Inheritance

Inheritance diagram of ShortBooleanFlag

Parameters:
classmethod __init_subclass__(*args, name=None, pattern='-with-{0}', falsePattern='-without-{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 when the value is True.

  • falsePattern (str) – This pattern is used to format an argument when the value is False.

  • kwargs (Any) – Any keyword argument.

  • name (str | None)

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 and value.

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.

property Value: ValueT

Get the internal value.

Returns:

Internal value.

__class_getitem__()

Parameterizes a generic class.

At least, parameterizing a generic class is the main thing this method does. For example, for some generic class Foo, this is called when we do Foo[int] - there, with cls=Foo and params=int.

However, note that this method is also called when defining generic classes in the first place with class Foo[T]: ….

__init__(value)

Initializes a BooleanFlag instance.

Parameters:

value (bool) – Initial value set for this argument instance.

Return type:

None

__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.BooleanFlag.LongBooleanFlag(value)[source]

Represents a BooleanFlag with a double dash.

Example:

  • True: --with-checks

  • False: --without-checks

Inheritance

Inheritance diagram of LongBooleanFlag

Parameters:
classmethod __init_subclass__(*args, name=None, pattern='--with-{0}', falsePattern='--without-{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 when the value is True.

  • falsePattern (str) – This pattern is used to format an argument when the value is False.

  • kwargs (Any) – Any keyword argument.

  • name (str | None)

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 and value.

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.

property Value: ValueT

Get the internal value.

Returns:

Internal value.

__class_getitem__()

Parameterizes a generic class.

At least, parameterizing a generic class is the main thing this method does. For example, for some generic class Foo, this is called when we do Foo[int] - there, with cls=Foo and params=int.

However, note that this method is also called when defining generic classes in the first place with class Foo[T]: ….

__init__(value)

Initializes a BooleanFlag instance.

Parameters:

value (bool) – Initial value set for this argument instance.

Return type:

None

__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.BooleanFlag.WindowsBooleanFlag(value)[source]

Represents a BooleanFlag with a slash.

Example:

  • True: /with-checks

  • False: /without-checks

Inheritance

Inheritance diagram of WindowsBooleanFlag

Parameters:
classmethod __init_subclass__(*args, name=None, pattern='/with-{0}', falsePattern='/without-{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 when the value is True.

  • falsePattern (str) – This pattern is used to format an argument when the value is False.

  • kwargs (Any) – Any keyword argument.

  • name (str | None)

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 and value.

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.

property Value: ValueT

Get the internal value.

Returns:

Internal value.

__class_getitem__()

Parameterizes a generic class.

At least, parameterizing a generic class is the main thing this method does. For example, for some generic class Foo, this is called when we do Foo[int] - there, with cls=Foo and params=int.

However, note that this method is also called when defining generic classes in the first place with class Foo[T]: ….

__init__(value)

Initializes a BooleanFlag instance.

Parameters:

value (bool) – Initial value set for this argument instance.

Return type:

None

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