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
initto carry out. - Terminal
- The real terminal.
Traits§
- Console
- The terminal, or a scripted stand-in.
Functions§
- confirm
- Ask a yes/no question.
default_yesdecides what Enter means. - real_
env - Whether an environment variable is set, in the real process.
- run
- Run the wizard against
console, consultingstorefor keys already held,sourcefor what each endpoint actually serves andquirks_sourcefor what the chosen model accepts.