Skip to main content

Module setup

Module setup 

Source
Expand description

Interactive setup wizard for krypt setup.

Reads [prompts.<name>] sections from .krypt.toml, asks the user questions via Prompter, and writes the collected values to destination files using one of four built-in writers:

  • gitconfig — merges key=value pairs into a git-style ini file.
  • hypr_vars — patches $VAR = value lines in a Hyprland config.
  • env — writes export K=V lines to a shell env file.
  • generic_template — substitutes {{key}} placeholders in a template.

§Default resolution order (first hit wins)

  1. read_var = "X" — read $X = <value> from the destination file.
  2. default_from prefix:
    • git:<key> — shell out to git config --get <key>. We deliberately keep this one shell-out because git-level user config (name, email, signing key) lives inside git’s own config system and cannot be read any other way without reimplementing the full git config search order. gix is only used for repo operations in update; it is not used here.
    • env:<VAR> — read env var.
    • field:<key> — value of an earlier field in this same run.
    • read_var:<X> — same as read_var shorthand.
  3. default = <toml value>.
  4. No default.

Structs§

FakeGitConfig
Fake git config for tests.
RealGitConfig
Shells out to the system git binary.
RealPrompter
Dialoguer-backed prompter used in production.
ScriptedPrompter
Pre-canned answers for unit tests. Pops answers in FIFO order.
SetupOpts
Inputs to setup.
SetupReport
Summary of a setup run.
YesPrompter
Returns each field’s computed default without prompting. Errors if a required field has no default.

Enums§

ResolveError
Errors from the default resolver.
SetupError
Errors from setup.

Traits§

GitConfig
Abstraction over git config --get <key> so tests can avoid a real git binary.
Prompter
Abstraction over interactive prompts so tests can inject scripted answers.

Functions§

setup
Run the interactive setup wizard.
setup_with_destinations
Run setup with per-section destination paths and optional template sources.
setup_with_destinations_and_srcs
Full entry point with both destination and source paths.
write_generic_template
Substitute {{key}} placeholders in a template file and write to dst. Missing keys leave the placeholder intact.