diff options
author | Andreas Guldstrand <andreas.guldstrand@gmail.com> | 2016-04-18 00:01:42 +0200 |
---|---|---|
committer | Andreas Guldstrand <andreas.guldstrand@gmail.com> | 2016-04-18 00:01:42 +0200 |
commit | 3591a89dbc5229de9659cbb8626ee82ca34c089b (patch) | |
tree | 05d98b0a998dc1856efc10d843954841dcdb0917 | |
parent | 37ded00a44421d02df657314efbe3a131f6916ff (diff) | |
download | sbotools2-3591a89dbc5229de9659cbb8626ee82ca34c089b.tar.xz |
sbosnap: Make argument checking more streamlined
-rwxr-xr-x | sbosnap | 16 |
1 files changed, 7 insertions, 9 deletions
@@ -46,18 +46,16 @@ GetOptions('help|h' => \$help, 'version|v' => \$vers); if ($help) { show_usage(); exit 0 } if ($vers) { show_version(); exit 0 } -if (!@ARGV) { show_usage(); exit 1 } - # check for a command and, if found, execute it -my $command; -if ($ARGV[0] =~ /fetch|update/) { - $command = $ARGV[0]; -} else { +$ARGV[0] //= ''; + +if ($ARGV[0] eq 'fetch') { + fetch_tree() +} elsif ($ARGV[0] eq 'update') { + update_tree() +} else { show_usage(); exit 1; } -if ($command eq 'fetch') { fetch_tree() } -elsif ($command eq 'update') { update_tree() } - exit 0; |