diff options
Diffstat (limited to 'src/cli.rs')
| -rw-r--r-- | src/cli.rs | 28 |
1 files changed, 18 insertions, 10 deletions
@@ -42,20 +42,18 @@ pub struct Args { impl Args { pub async fn run(self) -> Result<()> { let args = Args::parse(); - let name = args.autoscaling_group; let aws_context = AwsContext::from_env().await; - let apply_mode = if args.dry_run { - ApplyMode::DryRun - } else if args.apply { - ApplyMode::Apply - } else { - ApplyMode::DryRun - }; + let changes = named_asg_changes( + &aws_context, + &args.autoscaling_group, + &args.dns_name, + args.dns_ttl, + ) + .await?; - let changes = named_asg_changes(&aws_context, &name, &args.dns_name, args.dns_ttl).await?; - apply_mode + self.apply_mode() .apply( &aws_context, &changes.zone_id, @@ -66,4 +64,14 @@ impl Args { Ok(()) } + + fn apply_mode(&self) -> ApplyMode { + use ApplyMode::*; + match (self.dry_run, self.apply) { + (true, false) => DryRun, + (false, true) => Apply, + (false, false) => DryRun, + (true, true) => unreachable!("Cannot set --apply and --dry-run together"), + } + } } |
