Repository navigation
CLI help: explain piped and file input for sotto set #596
Description
The problem
sotto set --help lists the hidden prompt, --value and --stdin, but gives no examples or explanation of how piped input is handled. In particular, --stdin reads every byte through EOF without trimming: using echo can unintentionally store a trailing newline, while redirecting a file stores its complete contents as one value.
Make these existing input modes understandable from command help, so users can choose the right one without reading read_value().
Proposed approach
Add a short input explanation and examples to the Set subcommand help, following the existing Get, Import, History and Run help patterns.
Acceptance criteria
- Show
sotto set DATABASE_URLfor the hidden prompt andsotto set PRIVATE_KEY --stdin < ./example-key.txtfor file input. Explain that file input stores one complete value rather than importing dotenv assignments. - Include a clearly synthetic POSIX pipeline example, such as
printf '%s' 'example-value' | sotto set EXAMPLE --stdin, and explain whyprintfavoids the extra newline commonly added byecho. Do not present inline literal examples as a way to keep real credentials out of shell history. - Explain that
--stdinreads until EOF and preserves bytes, including line endings and trailing newlines; it does not trim or interpolate the input. - Retain the warning that
--valuecan expose a real credential in shell history/process arguments, and explain that--valueand--stdincannot be combined. - Clarify that choosing stdin replaces the value prompt, not initialisation or unlock requirements. For piped use, prepare/unlock the local store beforehand rather than suggesting a machine token grants write access.
- Check rendered
sotto set --helpfor readable formatting and valid examples. If adding a help regression test, use the existingCli::command()pattern and assert the essential input guidance without snapshotting the entire help output.
Evidence and starting points
Source-inspected current main 07237e2b3f817f342f6981a55b501487cc3a59e8 in a clean isolated checkout on macOS arm64:
crates/cli/src/main.rs:Command::Sethas noafter_helpexamples;read_value()usesread_to_endwithout trimming for stdin; the command callsensure_unlocked()before reading its value.- Nearby
import_help_explains_literal_and_quoted_valuesandhistory_and_rollback_help_explain_versionstests demonstrate rendering subcommand help without a real vault or server.
This is a help/documentation gap, not a reported input-processing bug. No real secret was supplied or stored. Open and closed issues and open PRs were checked; #208 covered dotenv import syntax, while this task explains the separate single-value set command.
Keep this contribution to help text and any focused help assertion. Do not change byte handling, validation, prompting, storage or encryption. Follow British English conventions and sign off commits with git commit -s.
Activity