Permalink
Browse files

better error message when type needed but not given

  • Loading branch information...
1 parent 9936b08 commit de8c3dbee2d826d35cdb7c6aa8cb79d5c67a1955 @xdg xdg committed May 4, 2012
Showing with 6 additions and 3 deletions.
  1. +6 −3 lib/Pantry/App/Command.pm
@@ -24,20 +24,23 @@ sub opt_spec {
sub validate_args {
my ( $self, $opt, $args ) = @_;
+ my ($command) = $self->command_names;
+ my $command_type = $self->command_type;
+
# redispatch to help if requested
if ( $opt->{help} ) {
- my ($command) = $self->command_names;
$self->app->execute_command(
$self->app->prepare_command("help", $command)
);
exit 0;
}
- my $command_type = $self->command_type;
-
# everything other than default needs a type to operate on
if ( $command_type ne 'DEFAULT' ) {
my ($type) = @$args;
+ unless ($type) {
+ $self->usage_error( "The '$command' command needs a type argument." );
+ }
unless ( grep { $type eq $_ } $self->valid_types ) {
$self->usage_error( "Invalid type '$type'" );
}

0 comments on commit de8c3db

Please sign in to comment.