Skip to content

Commit

Permalink
Add option to print the path to the target file
Browse files Browse the repository at this point in the history
  • Loading branch information
hinrik committed Jun 26, 2009
1 parent 8ae3d00 commit 8b83721
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 4 deletions.
3 changes: 3 additions & 0 deletions Changes
@@ -1,3 +1,6 @@
0.06
- Add -l/--only option to print the path to the target file

0.05 Fri Jun 26 05:48:02 GMT 2009
- Fix location of shared files (synopses)

Expand Down
17 changes: 13 additions & 4 deletions lib/App/Grok.pm
Expand Up @@ -20,12 +20,20 @@ sub new {

sub run {
get_options();
my ($target, $renderer);

if (defined $opt{file}) {
render_file($opt{file}, 'App::Grok::Pod6');
($target, $renderer) = ($opt{file}, 'App::Grok::Pod6');
}
else {
($target, $renderer) = find_target($ARGV[0]);
}

if ($opt{only}) {
print "$target\n";
}
else {
my $arg = shift @ARGV;
find_target($arg);
render_file($target, $renderer);
}
}

Expand All @@ -34,6 +42,7 @@ sub get_options {
'F|file=s' => \$opt{file},
'f|format=s' => \($opt{format} = 'ansi'),
'h|help' => sub { pod2usage(1) },
'l|only' => \$opt{only},
'T|no-pager' => \$opt{no_pager},
'v|version' => sub { print "grok $VERSION\n"; exit },
) or pod2usage();
Expand All @@ -53,7 +62,7 @@ sub find_target {
($target, $renderer) = find_file($arg) if !defined $target;

die "Target '$arg' not recognized\n" if !$target;
render_file($target, $renderer);
return ($target, $renderer);
}

sub find_synopsis {
Expand Down
1 change: 1 addition & 0 deletions script/grok
Expand Up @@ -17,6 +17,7 @@ B<grok> <options> <target>
-F FILE, --file=FILE A file to read Pod 6 from
-f FORMAT, --format=FORMAT The output format, ansi(default) or text
-h, --help Print this help message
-l, --only Only print the path to the target file
-T, --no-pager Send output to STDOUT without any pager
-v, --version Print version information
Expand Down

0 comments on commit 8b83721

Please sign in to comment.