diff options
| author | Jonas Häggqvist <rasher@rasher.dk> | 2009-06-25 23:26:17 +0000 |
|---|---|---|
| committer | Jonas Häggqvist <rasher@rasher.dk> | 2009-06-25 23:26:17 +0000 |
| commit | 5fe6ca6206e6ee201fb70e1c8b32fe066b2dfe9a (patch) | |
| tree | fb82fd18d3aa4c4231df7f0d209ea2d8da6deb85 | |
| parent | 4b578b61673bdb14d8a97a3d780c5abe98e86a45 (diff) | |
| download | rockbox-5fe6ca6206e6ee201fb70e1c8b32fe066b2dfe9a.zip rockbox-5fe6ca6206e6ee201fb70e1c8b32fe066b2dfe9a.tar.gz rockbox-5fe6ca6206e6ee201fb70e1c8b32fe066b2dfe9a.tar.bz2 rockbox-5fe6ca6206e6ee201fb70e1c8b32fe066b2dfe9a.tar.xz | |
More helpful output when illegal arguments are used.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@21519 a1c6a512-1295-4272-9138-f99709370657
| -rwxr-xr-x | tools/langtool.pl | 54 |
1 files changed, 36 insertions, 18 deletions
diff --git a/tools/langtool.pl b/tools/langtool.pl index 72108f4..2e95931 100755 --- a/tools/langtool.pl +++ b/tools/langtool.pl @@ -62,6 +62,12 @@ Usage langtool [--inplace] --options langfile1 [langfile2 ...] MOO } +sub error { + my ($msg) = @_; + printf("%s\n\nUse --help for usage help.\n", $msg); + exit(1); +} + use Getopt::Long; use strict; @@ -99,25 +105,37 @@ my $numids = @ids; my $numfiles = @ARGV; # Show help if necessary -if ( - $help - or # More than one option set - ($deprecate + $changesource + $changeid + $changetarget + $changedesc) != 1 - or # Do changeid, but either from or to is empty - ($changeid and ($from eq "" or $to eq "")) - or # Do changedesc, but to isn't set - ($changedesc and $to eq "") - or # Do changetarget, but - ($changetarget and ($from eq "" or $to eq "")) - or # Do deprecate, but no ids set - ($deprecate and $numids < 1) - or # Do changesource, but either target or to not set - ($changesource and ($s_target eq "" or $to eq "")) - or # More than one file passed, but inplace isn't set - ($numfiles > 1 and not $inplace) - ) { +if ($help) { usage(); - exit(1); + exit(); +} +# More than one option set (or none) +elsif (($deprecate + $changesource + $changeid + $changetarget + $changedesc) != 1) { + error("Exactly one of --deprecate, --changesource, --changeid, --changetarget,\n--changedesc must be used."); +} +# Do changeid, but either from or to is empty +elsif ($changeid and ($from eq "" or $to eq "")) { + error("--changid used, but either --from or --to not set"); +} +# Do changedesc, but to isn't set +elsif ($changedesc and $to eq "") { + error("--changedesc used, but --to not set"); +} +# Do changetarget, but from or to is empty +elsif ($changetarget and ($from eq "" or $to eq "")) { + error("--changetarget used, but --from or --to not set"); +} +# Do deprecate, but no ids set +elsif ($deprecate and $numids < 1) { + error("--deprecate used, but no IDs specified"); +} +# Do changesource, but either target or to not set +elsif ($changesource and ($s_target eq "" or $to eq "")) { + error("--changesource used, but --target or --to not set"); +} +# More than one file passed, but inplace isn't set +elsif ($numfiles > 1 and not $inplace) { + error("More than one file specified - this only works with --inplace"); } # Check that all supplied files exist before doing anything |