Sfoglia il codice sorgente

Groups are now runabble

Samuel W. Flint 4 anni fa
parent
commit
961801c0dc
2 ha cambiato i file con 23 aggiunte e 2 eliminazioni
  1. 2 2
      src/lib/group.rs
  2. 21 0
      src/lib/run.rs

+ 2 - 2
src/lib/group.rs

@@ -8,9 +8,9 @@ pub struct Group {
     #[serde(default)]
     name: String,
     #[serde(default)]
-    actions_after: Vec<String>,
+    pub actions_after: Vec<String>,
     #[serde(default)]
-    members: Vec<String>,
+    pub members: Vec<String>,
 }
 
 pub fn add(config: &mut Config, name: &String) {

+ 21 - 0
src/lib/run.rs

@@ -118,3 +118,24 @@ pub fn run_repository_creation(config: &Config, name: String) {
         None => panic!("No known repository named \"{}\".", name)
     }
 }
+
+pub fn run_group(config: &Config, name: String) {
+    let group = config.groups.get(&name.to_string());
+    match group {
+        Some(group) => {
+            for member in &group.members {
+                if config.repositories.contains_key(member) {
+                    run_repository_sync(&config, member.to_string());
+                } else if config.groups.contains_key(member) {
+                    run_group(&config, member.to_string());
+                } else {
+                    println!("\"{}\" is neither a group nor a repository.", member);
+                }
+            }
+            for action in &group.actions_after {
+                run_action(&config, action.to_string());
+            }
+        },
+        None => panic!("No known group named \"{}\".", name)
+    }
+}