Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions crates/cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -166,13 +166,19 @@ enum Command {
/// Remove a secret.
Rm { name: String },
/// Show a secret's version history (from the server; run after `login`).
#[command(
after_help = "Examples:\n sotto history DATABASE_URL\n sotto history DATABASE_URL --reveal\n\nHistory and rollback use the server and require login and an unlocked local store. History normally shows version numbers and sizes; --reveal prints plaintext values."
)]
History {
name: String,
/// Show each version's value, not just its number and size.
#[arg(long)]
reveal: bool,
},
/// Restore an old version of a secret as a new version (local until you `push`).
#[command(
after_help = "Examples:\n sotto history DATABASE_URL\n sotto rollback DATABASE_URL 2\n sotto push\n\nChoose an available version from history and pass its number without the displayed v prefix. Rollback restores that value as a new local version without erasing history; sotto push synchronises it. History and rollback require login and an unlocked local store."
)]
Rollback {
name: String,
/// The version to restore (see `sotto history`).
Expand Down Expand Up @@ -1422,6 +1428,26 @@ mod tests {
assert!(help.contains("Sotto options go before --"));
}

#[test]
fn history_and_rollback_help_explain_versions() {
let mut command = Cli::command();
let history = command
.find_subcommand_mut("history")
.expect("history subcommand should exist")
.render_long_help()
.to_string();
assert!(history.contains("sotto history DATABASE_URL --reveal"));
assert!(history.contains("--reveal prints plaintext values"));

let rollback = command
.find_subcommand_mut("rollback")
.expect("rollback subcommand should exist")
.render_long_help()
.to_string();
assert!(rollback.contains("sotto rollback DATABASE_URL 2"));
assert!(rollback.contains("without erasing history"));
}

#[test]
fn run_parser_preserves_forwarded_arguments() {
let cli = Cli::try_parse_from(["sotto", "run", "--", "npm", "start"])
Expand Down
Loading