summaryrefslogtreecommitdiff
path: root/src/cli.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/cli.rs')
-rw-r--r--src/cli.rs28
1 files changed, 18 insertions, 10 deletions
diff --git a/src/cli.rs b/src/cli.rs
index 96758be..0362b5e 100644
--- a/src/cli.rs
+++ b/src/cli.rs
@@ -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"),
+ }
+ }
}