Skip to content

Commit

Permalink
Simplify the mutex options error message.
Browse files Browse the repository at this point in the history
  • Loading branch information
petdance committed Dec 15, 2019
1 parent ea62958 commit 026417f
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 24 deletions.
29 changes: 16 additions & 13 deletions Changes
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,6 @@ History file for ack 3. https://beyondgrep.com/

NEXT
========================================
[FIXES]
Fixed the behavior of --break and --heading. Using --break would
implicitly set --noheading, and --heading would implicitly set --nobreak.

The -x and --files-from options can't be used together. ack will now warn
you if you try.

The -v and -o/--output options can't be used together. ack will now warn
you if you try.

Fixed the minimum version of the Getopt::Long module required. (GH #287)


[FEATURES]
Added many new file and directory exclusions to speed up file selection.
* Python's *.pyc, *.pyd and *.pyo compiled files
Expand All @@ -41,6 +28,22 @@ offending part of the regex. For example:
Regex: status: (open|closed|in progress
^---HERE Unmatched ( in regex

Improved the error message when ack gets passed two options that can't be
used together.


[FIXES]
Fixed the behavior of --break and --heading. Using --break would
implicitly set --noheading, and --heading would implicitly set --nobreak.

The -x and --files-from options can't be used together. ack will now warn
you if you try.

The -v and -o/--output options can't be used together. ack will now warn
you if you try.

Fixed the minimum version of the Getopt::Long module required. (GH #287)


v3.2.0 Sun Nov 3 22:52:18 CST 2019
========================================
Expand Down
11 changes: 5 additions & 6 deletions lib/App/Ack/ConfigLoader.pm
Original file line number Diff line number Diff line change
Expand Up @@ -234,8 +234,7 @@ sub get_arg_spec {
* Add your option to t/Util.pm#get_expected_options
* Add your option's description and aliases to dev/generate-completion-scripts.pl
* Go through the list of options already available, and consider
whether your new option can be considered mutually exclusive
with another option.
whether your new option can be considered mutex with another option.
=end Adding-Options
Expand Down Expand Up @@ -611,7 +610,7 @@ sub process_args {

my $type_specs = _process_filetypes(\%opt, $arg_sources);

_check_for_mutually_exclusive_options( $type_specs );
_check_for_mutex_options( $type_specs );

_process_other(\%opt, $type_specs, $arg_sources);
while ( @{$arg_sources} ) {
Expand Down Expand Up @@ -722,8 +721,8 @@ sub read_rcfile {
}


# Verifies no mutually-exclusive options were passed. Dies if they were.
sub _check_for_mutually_exclusive_options {
# Verifies no mutex options were passed. Dies if they were.
sub _check_for_mutex_options {
my $type_specs = shift;

my $mutex = mutex_options();
Expand All @@ -738,7 +737,7 @@ sub _check_for_mutually_exclusive_options {
if ( $mutex->{$i}{$j} ) {
my $x = $raw->[ $used->{$i} ];
my $y = $raw->[ $used->{$j} ];
App::Ack::die( "Options '$x' and '$y' are mutually exclusive" );
App::Ack::die( "Options '$x' and '$y' can't be used together." );
}
}
}
Expand Down
10 changes: 5 additions & 5 deletions t/mutex-options.t
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ subtest q{Verify that "options" that follow -- aren't factored into the mutual e
is(get_rc(), 0, 'The ack command should not fail');
};

subtest q{Verify that mutually exclusive options in different sources don't cause a problem} => sub {
subtest q{Verify that mutex options in different sources don't cause a problem} => sub {
my $ackrc = <<'HERE';
--group
HERE
Expand Down Expand Up @@ -224,13 +224,13 @@ sub are_mutually_exclusive {
my $opt2_re = quotemeta($opt2);

my $error = $stderr->[0] || ''; # avoid undef warnings
if ( $error =~ /Options '$opt1_re' and '$opt2_re' are mutually exclusive/ ||
$error =~ /Options '$opt2_re' and '$opt1_re' are mutually exclusive/ ) {
if ( $error =~ /Options '$opt1_re' and '$opt2_re' can't be used together/ ||
$error =~ /Options '$opt2_re' and '$opt1_re' can't be used together/ ) {

pass( qq{Error message resembles "Options '$opt1' and '$opt2' are mutually exclusive"} );
pass( qq{Error message resembles "Options '$opt1' and '$opt2' can't be used together"} );
}
else {
fail( qq{Error message does not resemble "Options '$opt1' and '$opt2' are mutually exclusive"} );
fail( qq{Error message does not resemble "Options '$opt1' and '$opt2' can't be used together"} );
diag("Error message: '$error'");
}
};
Expand Down

0 comments on commit 026417f

Please sign in to comment.