feat(wizard): add password and number option types#9
Merged
Conversation
Two new option types for wizard configs: - password: masked entry that renders as **** everywhere oz prints a command or answer (dry-run, confirmation prompt, oz run show, pins/presets editors) and is never written to persisted state (last-used, presets, pins) — every run re-prompts. An optional `secret_env: NAME` delivers the value through the child process environment instead of argv, keeping it off the process list on Linux; env wins over flag when both are set. - number: integer/float entry with optional inclusive min/max bounds; rejects non-numeric, out-of-range, and non-finite (NaN/Inf) input, and omits its flag when left blank. Redaction is enforced at the render surfaces (Part.Secret + FormatAnswer) and at every persistence/display boundary (stripSecrets, applied on save and load), while PlainParts/FormatCommand keep the real value for exec and hermetic goldens. Config guardrails reject secret_env on non-password types, invalid env var names, min/max on non-number types, min > max, and positional passwords.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Wizards can now collect two kinds of input they couldn't before: secrets and bounded numbers.
A
passwordoption masks input as it's typed, renders as****everywhere oz prints a command or answer (dry-run, confirmation prompt,oz run show, and the pins/presets editors), and is never written to last-used state, presets, or pins — every run re-prompts. Withsecret_env: NAME, oz hands the value to the wrapped command through its environment instead ofargv, keeping it off the process list on Linux.A
numberoption accepts integer or float input with optional inclusivemin/maxbounds, rejecting non-numeric, out-of-range, and non-finite (NaN/Inf) values, and omits its flag when left blank.What changed
OptionPasswordandOptionNumberrun through the enum, validator, field engine, and command builder, each added to the exhaustive switches so no render or build path silently falls through to a default.Part.Secretmasks at the command renderer andFormatAnswermasks at the answer renderer, whilePlainParts/FormatCommandkeep the true value for exec and hermetic goldens. Persistence and display paths route throughstripSecrets, which drops password-typed keys on every save and load — so a secret that predates the feature, or a value retyped into a field that became a password, is dropped rather than restored or shown.RunWithEnvappendsNAME=valueto the child environment; whensecret_envis set the option emits nothing intoargv. If bothsecret_envandflagare present, env delivery wins and oz prints a warning.secret_envrequires a valid env-var name and thepasswordtype;min/maxrequirenumberwithmin <= max; apositionalpassword is rejected outright, since a positional secret can be neither masked nor kept off argv.Design decisions
****. SeparatingPart.Secret(renderer) fromPlainParts(exec) is what lets both hold at once.numberreusesinput. Only entry validation differs, soNumberFieldembedsInputFieldand injects its numeric validator through avalidateFnhook instead of duplicating the update loop.secret_envis strictly more private than a flag on Linux and no less private elsewhere; the README states the platform scope and the argv-visibility limitation of the flag fallback plainly, rather than implying a universal guarantee.Validation
task lint-> 0 issues.task test-> all packages pass, including new coverage for: secret masking across equals-style, space-style, and space-style-with-=-in-value flags; raw-value fidelity on the exec/golden path;NaN/Infrejection and min/max bounds;stripSecretson the preset/pins/save paths;secret_envenv delivery, name validation, and the both-set warning; and positional-password rejection.No live TUI recording is attached — the behavior is covered by the test suite above; the interactive prompt itself is a standard Bubbletea field.