Skip to content

Commit

Permalink
feat(cli): add --ci flag to signer generate, closes #6089 (#6097)
Browse files Browse the repository at this point in the history
Co-authored-by: Lucas Nogueira <lucas@tauri.studio>
  • Loading branch information
amrbashir and lucasfernog committed Jan 19, 2023
1 parent e0631d3 commit 8fb1df8
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
6 changes: 6 additions & 0 deletions .changes/cli-sign-non-interactive.md
Original file line number Diff line number Diff line change
@@ -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.
12 changes: 9 additions & 3 deletions tooling/cli/src/signer/generate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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");

Expand Down

0 comments on commit 8fb1df8

Please sign in to comment.