InputFlag

The InputFlag object represents a flag entered by the user. It is created as a result of processing user input and contains information about the recognized flag: its name, prefix, value, and validation status.

See also

Documentation for Flag — class for registering a flag.

Documentation for ValidationStatus — flag validation statuses.


Warning

Instances of this class are not intended for direct creation. They are contained in the Response object.

Attributes:

name

Name of the entered flag.

prefix

Flag prefix: -, --, or ---.

input_value

Value passed with the flag. Can be '' (empty string) for flags without values.

status

Flag validation status: ValidationStatus.VALID, ValidationStatus.INVALID, or ValidationStatus.UNDEFINED.


Properties

string_entity

1@property
2string_entity(self) -> str

Returns the string representation of the flag in the format prefix + name.

return:

String representation of the flag


Magic Methods

__str__

1__str__(self) -> str

Returns the string representation of the flag along with its value.

return:

String in the format flag value.

Usage example:

 1from argenta.command.flag import InputFlag, ValidationStatus
 2
 3flag_with_value = InputFlag(
 4    name="output", prefix="--", input_value="result.txt", status=ValidationStatus.VALID
 5)
 6
 7flag_without_value = InputFlag(
 8    name="help", prefix="-", input_value='', status=ValidationStatus.VALID
 9)
10
11# String representation includes value
12print(str(flag_with_value))  # --output result.txt
13print(str(flag_without_value))  # -help

__repr__

1__repr__(self) -> str

Returns the debug representation of the object.

return:

String in the format InputFlag<prefix=..., name=..., value=..., status=...>.

Usage example:

 1from argenta.command.flag import InputFlag, ValidationStatus
 2
 3flag = InputFlag(
 4    name="config",
 5    prefix="--",
 6    input_value="settings.json",
 7    status=ValidationStatus.VALID,
 8)
 9
10# Debug representation of the object
11print(repr(flag))
12# InputFlag<prefix='--', name='config', value='settings.json', status=ValidationStatus.VALID>

__eq__

1__eq__(self, other: object) -> bool

Compares two entered flags for equality by name.

param other:

Object to compare.

return:

True if flag names match, otherwise False.

Two entered flags are considered equal if their names match.