summaryrefslogtreecommitdiffstats
path: root/bin
diff options
context:
space:
mode:
authorMario Krehl <mkrehl@science-computing.de>2016-09-07 10:31:00 +0200
committerMario Krehl <mkrehl@science-computing.de>2016-09-07 10:31:00 +0200
commit7023d1f2027b1402ca837efc626029e2cb1d687f (patch)
tree524996d53f9272df3affa7c8056bf255b3d490d6 /bin
parente6d48cb31ab6eee22ae5db3e8ace8f882835303f (diff)
Add check if given subcommand is supported
Diffstat (limited to 'bin')
-rw-r--r--bin/src/main.rs9
1 files changed, 9 insertions, 0 deletions
diff --git a/bin/src/main.rs b/bin/src/main.rs
index 885f0163..de383068 100644
--- a/bin/src/main.rs
+++ b/bin/src/main.rs
@@ -175,6 +175,13 @@ fn main() {
Some(values) => values.collect(),
None => Vec::new()
};
+
+ if !get_commands().contains(&String::from(subcommand)) {
+ println!("No such command: 'imag-{}'", subcommand);
+ println!("See 'imag --help' for available subcommands");
+ exit(2);
+ }
+
debug!("Calling 'imag-{}' with args: {:?}", subcommand, subcommand_args);
match Command::new(format!("imag-{}", subcommand))
@@ -198,6 +205,8 @@ fn main() {
debug!("Error calling the subcommand");
match e.kind() {
ErrorKind::NotFound => {
+ // With the check above, this absolutely should not happen.
+ // Keeping it to be safe
println!("No such command: 'imag-{}'", subcommand);
println!("See 'imag --help' for available subcommands");
exit(2);