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
BooleanFlag
: Class and base-class for all BooleanFlag classes, which represents a flag argument with different pattern for anShortBooleanFlag
: Represents aBooleanFlag
with a single dash.LongBooleanFlag
: Represents aBooleanFlag
with a double dash.WindowsBooleanFlag
: Represents aBooleanFlag
with a slash.
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
andfalsePattern
are expected.Example:
True:
with-checks
False:
without-checks
Inheritance
- classmethod __init_subclass__(*args, name=None, pattern='with-{0}', falsePattern='without-{0}', **kwargs)[source]
This method is called when a class is derived.
- __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:
- Returns:
Formatted argument.
- Raises:
ValueError – If internal name is None.
- 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:
- 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
- classmethod __init_subclass__(*args, name=None, pattern='-with-{0}', falsePattern='-without-{0}', **kwargs)[source]
This method is called when a class is derived.
- 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:
- Returns:
Formatted argument.
- Raises:
ValueError – If internal name is None.
- 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:
- 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
- classmethod __init_subclass__(*args, name=None, pattern='--with-{0}', falsePattern='--without-{0}', **kwargs)[source]
This method is called when a class is derived.
- 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:
- Returns:
Formatted argument.
- Raises:
ValueError – If internal name is None.
- 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:
- 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
- classmethod __init_subclass__(*args, name=None, pattern='/with-{0}', falsePattern='/without-{0}', **kwargs)[source]
This method is called when a class is derived.
- 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:
- Returns:
Formatted argument.
- Raises:
ValueError – If internal name is None.
- 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:
- Returns:
Argument formatted and enclosed in double quotes.