Browse Source

Update method of running commands

Samuel W. Flint 3 years ago
parent
commit
f59127f94b
2 changed files with 15 additions and 1 deletions
  1. 6 0
      src/cli.yml
  2. 9 1
      src/main.rs

+ 6 - 0
src/cli.yml

@@ -27,6 +27,12 @@ subcommands:
             multiple: true
             value_name: REPO_OR_GROUP
             help: The name of a repository or group to sync
+        - command:
+            short: C
+            long: comand
+            value_name: COMMAND
+            help: Run named command
+            takes_value: true
   - repository:
       about: Create and manage repositories
       settings:

+ 9 - 1
src/main.rs

@@ -34,7 +34,15 @@ fn main() {
     }
 
     match matches.subcommand_name() {
-        Some("run") => run::run(&configuration, matches.subcommand_matches("run").unwrap().values_of("name").unwrap()),
+        Some("run") => if let Some(matches) = matches.subcommand_matches("run") {
+            if matches.is_present("command") {
+                println!("Running with command");
+                run::run_with_command(&configuration, matches.value_of("command").unwrap().to_string(),
+                                      matches.values_of("name").unwrap());
+            } else {
+                run::run(&configuration, matches.values_of("name").unwrap());
+            }
+        },
         Some("repository") => if let Some(matches) = matches.subcommand_matches("repository") {
             match matches.subcommand_name() {
                 Some("register") => if let Some(matches) = matches.subcommand_matches("register") {