Skip to main content

Module wizard

Module wizard 

Source
Expand description

The interactive half of drep init.

drep init --provider kimi is the scripted path and stays exactly as it was. This is what runs when nobody passed --provider and there is a person at the other end: pick a provider, paste a key, add a fallback, choose the hooks, decide whether the config is committed.

§Everything goes through Console

The wizard never touches stdin or stdout directly. That is what makes it testable without a terminal - the tests drive it with a scripted queue of answers and read back everything it said - and it is the same reason init::run_to writes to a &mut dyn Write rather than to stdout.

It also keeps the one genuinely awkward operation, reading a key without echoing it, behind a single method. rpassword is used for that in production and nothing in this file knows about it.

§The wizard decides, it does not act

run returns a Plan. It writes no file, stores no key and installs no hook. init applies the plan afterwards, in the same order and through the same functions the flag path uses, so an answer given interactively cannot reach a different code path than the equivalent flag.

Structs§

Deps
What the wizard needs from the outside world.
Plan
What the wizard decided, for init to carry out.
Terminal
The real terminal.

Traits§

Console
The terminal, or a scripted stand-in.

Functions§

confirm
Ask a yes/no question. default_yes decides what Enter means.
real_env
Whether an environment variable is set, in the real process.
run
Run the wizard against console, consulting store for keys already held, source for what each endpoint actually serves and quirks_source for what the chosen model accepts.