diff --git a/.changes/cli-sign-non-interactive.md b/.changes/cli-sign-non-interactive.md new file mode 100644 index 000000000..473dad10c --- /dev/null +++ b/.changes/cli-sign-non-interactive.md @@ -0,0 +1,6 @@ +--- +"cli.rs": patch +"cli.js": patch +--- + +Add `--ci` flag and respect the `CI` environment variable on the `signer generate` command. In this case the default password will be an empty string and the CLI will not prompt for a value. diff --git a/tooling/cli/src/signer/generate.rs b/tooling/cli/src/signer/generate.rs index 03a518ef4..5a1094bf6 100644 --- a/tooling/cli/src/signer/generate.rs +++ b/tooling/cli/src/signer/generate.rs @@ -21,11 +21,17 @@ pub struct Options { /// Overwrite private key even if it exists on the specified path #[clap(short, long)] force: bool, + /// Skip prompting for values + #[clap(short, long)] + ci: bool, } -pub fn command(options: Options) -> Result<()> { - if options.password.is_none() { - println!("Generating new private key without password.") +pub fn command(mut options: Options) -> Result<()> { + options.ci = options.ci || std::env::var("CI").is_ok(); + + if options.ci && options.password.is_none() { + println!("Generating new private key without password."); + options.password.replace("".into()); } let keypair = generate_key(options.password).expect("Failed to generate key");