Return non-zero exit code when invalid option is specified (#34)
Also add a unit test for this. Fixes #34: https://github.com/aspiers/stow/issues/34
This commit is contained in:
parent
1e9fa23d2e
commit
e79c5938bc
2 changed files with 6 additions and 2 deletions
|
@ -539,7 +539,7 @@ sub process_options {
|
|||
push @pkgs_to_stow, $_[0];
|
||||
}
|
||||
},
|
||||
) or usage();
|
||||
) or usage('');
|
||||
|
||||
usage() if $options{help};
|
||||
version() if $options{version};
|
||||
|
|
6
t/cli.t
Normal file → Executable file
6
t/cli.t
Normal file → Executable file
|
@ -8,7 +8,7 @@ use strict;
|
|||
use warnings;
|
||||
|
||||
use File::Basename;
|
||||
use Test::More tests => 1;
|
||||
use Test::More tests => 3;
|
||||
|
||||
use testutil;
|
||||
|
||||
|
@ -47,4 +47,8 @@ my $STOW = 'bin/stow';
|
|||
`$STOW --help`;
|
||||
is($?, 0, "--help should return 0 exit code");
|
||||
|
||||
my $err = `$STOW --foo 2>&1`;
|
||||
is($? >> 8, 1, "unrecognised option should return 1 exit code");
|
||||
like($err, qr/^Unknown option: foo$/m, "unrecognised option should be listed");
|
||||
|
||||
# vim:ft=perl
|
||||
|
|
Loading…
Reference in a new issue