Interview#
- class graftkit.Interview[source]#
Bases:
FrozenModelA command’s questions and consents, and where their dynamic parts come from.
- Attributes:
- questionstuple[Question, …]
The questions, in the order they are asked.
- consentstuple[Consent, …]
The confirmations the command may ask for while it runs.
- choicesdict[str, Callable[[Mapping[str, Any], str | None], Sequence[str]]]
Dynamic choice, item and suggestion sources, by name.
- defaultsdict[str, Callable[[Mapping[str, Any], str | None], str | None]]
Dynamic default sources, by name.
- offlinefrozenset[str]
The choice sources that are local and cheap:
--describelists their values and only names the others.- factsCallable[[Mapping[str, Any]], Mapping[str, Any]] | None
Facts derived from the answers and options, for conditions.
- custom_kindsdict[str, CustomKind]
The custom kinds the questions use, by name.
- groupsdict[str, str]
Bundled question groups, by name, each with what it covers in one line.
consent_keysfrozenset[str]The keys of the declared consents.
Methods
add_arguments(parser)Add one flag per question to
parser, grouped by section.run(console, interaction, flag_values, options)Answer every applicable question from its flag, a prompt, or its default.
describe()Return the interview's part of the
--describedocument.- add_arguments(parser: ArgumentParser) None[source]#
Add one flag per question to
parser, grouped by section.- Parameters:
- parserArgumentParser
The command’s argument parser.
- run(console: Console, interaction: Interaction, flag_values: Mapping[str, Any], options: Mapping[str, Any]) dict[str, Any][source]#
Answer every applicable question from its flag, a prompt, or its default.
- Parameters:
- consoleConsole
Where to ask.
- interactionInteraction
Whether the run may prompt.
- flag_valuesMapping[str, Any]
The parsed flags, by question key;
Noneor[]if not given.- optionsMapping[str, Any]
The command’s option values, which conditions may test.
- Returns:
- dict[str, Any]
The answers of the questions that apply, by key.
- Raises:
- CliError
A flag answers a question that does not apply, a value fails validation, or a run that cannot prompt misses a required answer.