summary history branches tags files
commit:f7f757b655469e04484523861d84b66c9d9fb0fc
author:Trevor Bentley
committer:Trevor Bentley
date:Wed Jan 15 19:16:35 2025 +0100
parents:b7937d0fb60fa59cf8ee5df14e321a8b663438af
cli: make policies optional
diff --git a/src/main.rs b/src/main.rs
line changes: +10/-4
index bb6026e..cb27920
--- a/src/main.rs
+++ b/src/main.rs
@@ -64,11 +64,11 @@ struct PwwArgs {
 
     /// Policy for which metadata should be updated
     #[arg(long)]
-    file_update_policy: FileUpdatePolicy,
+    file_update_policy: Option<FileUpdatePolicy>,
 
     /// Policy for how changes should be made to the specified tags.
     #[arg(long)]
-    tag_update_policy: TagUpdatePolicy,
+    tag_update_policy: Option<TagUpdatePolicy>,
 
     /// Print information about which tags are written
     #[arg(short = 'v', long)]
@@ -325,14 +325,20 @@ impl PwwConfig {
 
     fn tag_update_policy(&self) -> TagUpdatePolicy {
         match &self.cli {
-            Some(c) => c.tag_update_policy.clone(),
+            Some(c) => match &c.tag_update_policy {
+                Some(p) => p.clone(),
+                _ => self.tag_update_policy.clone(),
+            },
             _ => self.tag_update_policy.clone(),
         }
     }
 
     fn file_update_policy(&self) -> FileUpdatePolicy {
         match &self.cli {
-            Some(c) => c.file_update_policy.clone(),
+            Some(c) => match &c.file_update_policy {
+                Some(p) => p.clone(),
+                _ => self.file_update_policy.clone(),
+            },
             _ => self.file_update_policy.clone(),
         }
     }