Option#

class cli_interview_kit.Option[source]#

Bases: FrozenModel

A plain option or positional argument; not an interview question.

Options choose what a command does (--check, --dry-run) or name what it acts on. Anything the user could be asked belongs in the interview instead.

Attributes:
deststr

The name the value is read by, in snake_case; the flag is -- plus the name with dashes.

helpstr

Help text.

kindLiteral[‘switch’, ‘value’, ‘append’, ‘positional’]

switch is an on/off flag; value takes one value; append is repeatable; positional is an argument.

metavarstr | None

Value placeholder in help.

choicestuple[str, …]

Allowed values.

nargsLiteral[‘?’, ‘*’, ‘+’] | None

A positional’s arity, e.g. "*".

convertCallable[[str], Any] | None

Converts and checks a value; raising ValueError is a usage error.

exclusivestr | None

Options sharing this name are mutually exclusive.

flagstr

The option’s flag, or its name for a positional.

Methods

describe()

Describe the option as --questions lists it.

property flag: str#

The option’s flag, or its name for a positional.

describe() → dict[str, Any][source]#

Describe the option as --questions lists it.

Returns:
dict[str, Any]

The option’s flag, kind and help.