diff --git a/ack b/ack index 8d6ad61a..ac46bcf9 100755 --- a/ack +++ b/ack @@ -1426,7 +1426,7 @@ B<--flush> flushes output immediately. This is off by default unless ack is running interactively (when output goes to a pipe or file). -=item B<-f> +=item B<-f>, B<--files> Only print the files that would be searched, without actually doing any searching. PATTERN must not be specified, or it will be taken diff --git a/dev/generate-completion-scripts.pl b/dev/generate-completion-scripts.pl index 0b2c332b..9c1f1cca 100755 --- a/dev/generate-completion-scripts.pl +++ b/dev/generate-completion-scripts.pl @@ -30,6 +30,7 @@ '--count' => 'print a count of matching lines for each input file', '--create-ackrc' => 'dumps default ack options to standard output', '--dump' => 'writes the list of loaded options and where they came from', + '--files' => 'only print files that would be searched', '--files-from' => 'specifies the list of files to search within FILE', '--files-with-matches' => 'only print filenames of matching files', '--files-without-matches' => 'only print filenames of non-matching files', @@ -67,7 +68,6 @@ '--with-filename' => 'print the filename for each match', '--word-regexp' => 'force PATTERN to match only whole words', '-1' => 'stops after reporting first match', - '-f' => 'only print files that would be searched', '-g' => 'only print files whose names match PATTERN', '-o' => 'only print the part of each matching line that matches PATTERN', '-s' => 'suppress error messages about nonexistent or unreadable files', @@ -79,6 +79,7 @@ '--before-context' => ['-B'], '--context' => ['-C'], '--count' => ['-c'], + '--files' => ['-f'], '--no-filename' => ['-h'], '--with-filename' => ['-H'], '--files-with-matches' => ['-l'], diff --git a/lib/App/Ack.pm b/lib/App/Ack.pm index 146281e0..ccd2b5b9 100644 --- a/lib/App/Ack.pm +++ b/lib/App/Ack.pm @@ -225,7 +225,7 @@ Default switches may be specified in an .ackrc file. If you want no dependency on the environment, turn it off with --noenv. File select actions: - -f Only print the files selected, without + -f, --files Only print the files selected, without searching. The PATTERN must not be specified. -g Same as -f, but only select files matching PATTERN. diff --git a/lib/App/Ack/ConfigLoader.pm b/lib/App/Ack/ConfigLoader.pm index f649c4eb..bb06afa1 100644 --- a/lib/App/Ack/ConfigLoader.pm +++ b/lib/App/Ack/ConfigLoader.pm @@ -298,7 +298,7 @@ sub get_arg_spec { $opt->{noenv_seen} = 1; } }, - f => \$opt->{f}, + 'f|files' => \$opt->{f}, 'files-from=s' => \$opt->{files_from}, 'filter!' => \$App::Ack::is_filter_mode, flush => sub { $| = 1 }, diff --git a/t/Util.pm b/t/Util.pm index a2de5061..de25cc88 100644 --- a/t/Util.pm +++ b/t/Util.pm @@ -852,6 +852,7 @@ sub get_expected_options { '--create-ackrc', '--dump', '--env', + '--files', '--files-from', '--files-with-matches', '--files-without-matches', diff --git a/t/longopts.t b/t/longopts.t index 107a8543..bfa2bd14 100644 --- a/t/longopts.t +++ b/t/longopts.t @@ -11,7 +11,7 @@ This tests whether ack's command line options work as expected. use Test::More; -plan tests => 52; +plan tests => 56; use lib 't'; use Util; @@ -136,6 +136,17 @@ for my $arg ( qw( -Q --literal ) ) { my $expected = reslash( 't/swamp/options.pl' ); +# Files +for my $arg ( qw( -f --files ) ) { + my @files = qw( t/swamp/options.pl ); + my $results = run_ack( $arg, @files ); + like( + $results, + qr{\Q$expected}, + qq{$arg prints files that would be searched} + ); +} + # Files with matches for my $arg ( qw( -l --files-with-matches ) ) { my @args = ( $arg, 'use strict' );