Skip to content

Commit d209cd7

Browse files
committed
fix: multiple targets cant be specified
This fixes [325](serokell#325) by manually merging `targets` with `target` if needed. It might be related to this [upstream](clap-rs/clap#5115) issue.
1 parent 6bc76b8 commit d209cd7

File tree

1 file changed

+16
-7
lines changed

1 file changed

+16
-7
lines changed

src/cli.rs

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,13 @@ use tokio::process::Command;
2424
#[command(version = "1.0", author = "Serokell <https://serokell.io/>")]
2525
pub struct Opts {
2626
/// The flake to deploy
27-
#[arg(group = "deploy")]
2827
target: Option<String>,
2928

3029
/// A list of flakes to deploy alternatively
31-
#[arg(long, group = "deploy")]
30+
#[arg(long)]
3231
targets: Option<Vec<String>>,
3332
/// Treat targets as files instead of flakes
34-
#[clap(short, long)]
33+
#[arg(short, long)]
3534
file: Option<String>,
3635
/// Check signatures when using `nix copy`
3736
#[arg(short, long)]
@@ -677,10 +676,20 @@ pub async fn run(args: Option<&ArgMatches>) -> Result<(), RunError> {
677676
error!("Cannot use both --dry-activate & --boot!");
678677
}
679678

680-
let deploys = opts
681-
.clone()
682-
.targets
683-
.unwrap_or_else(|| vec![opts.clone().target.unwrap_or_else(|| ".".to_string())]);
679+
let deploys;
680+
if opts.targets.is_some() && opts.target.is_some() {
681+
// SAFETY: checked before
682+
let mut targets = opts.targets.unwrap();
683+
targets.push(opts.target.unwrap());
684+
deploys = targets;
685+
} else {
686+
deploys = opts
687+
.clone()
688+
.targets
689+
.unwrap_or_else(|| vec![opts.clone().target.unwrap_or_else(|| ".".to_string())]);
690+
}
691+
692+
debug!("Deploying the following configurations {:?}", deploys);
684693

685694
let deploy_flakes: Vec<DeployFlake> =
686695
if let Some(file) = &opts.file {

0 commit comments

Comments
 (0)