Skip to content

Commit

Permalink
Start some reorganization
Browse files Browse the repository at this point in the history
* Put the bulk of the code into App::Grok

* Bundle a share/ dir
  • Loading branch information
hinrik committed Jun 2, 2009
1 parent 574ad07 commit 3850bd8
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 36 deletions.
1 change: 1 addition & 0 deletions MANIFEST
@@ -1,4 +1,5 @@
script/grok
lib/App/Grok.pm
script/grok.pod
p6/grok
Makefile.PL
Expand Down
1 change: 1 addition & 0 deletions Makefile.PL
Expand Up @@ -10,6 +10,7 @@ abstract ('Perl 6 documentation reader');
version_from ('script/grok');
install_script ('script/grok');
no_index (directory => 't_source');
install_share (install_share => 'share');
license ('artistic_2');
requires ('Getopt::Long' => '2.33');
requires ('Perl6::Perldoc' => '0.0.5');
Expand Down
37 changes: 37 additions & 0 deletions lib/App/Grok.pm
@@ -0,0 +1,37 @@
package App::Grok;

# blows up if we use strict before this, damn source filter
use Perl6::Perldoc::Parser;

use strict;
use warnings;
use Getopt::Long qw(:config bundling);
use Pod::Usage;

our $VERSION = '0.03';

sub run {
GetOptions(
'F|file=s' => \my $from_file,
'f|format=s' => \(my $format = 'ansi'),
'h|help' => sub { pod2usage(1) },
'v|version' => sub { print "grok $VERSION\n"; exit },
) or pod2usage();

if (!defined $from_file) {
die "You must supply --file with an argument; see --help\n";
}

if ($format ne 'text' && $format ne 'ansi') {
die "Format '$format' is unsupported\n";
}

$format eq 'text'
? require Perl6::Perldoc::To::Text
: require Perl6::Perldoc::To::Ansi
;

print Perl6::Perldoc::Parser->parse($from_file, {all_pod=>'auto'})
->report_errors()
->to_text();
}
38 changes: 2 additions & 36 deletions script/grok
@@ -1,42 +1,8 @@
#!/usr/bin/env perl

package grok;

# blows up if we use strict before this, damn source filter
use Perl6::Perldoc::Parser;

use strict;
use warnings;
use Getopt::Long qw(:config bundling);
use Pod::Usage;

our $VERSION = '0.03';

GetOptions(
'F|file=s' => \my $from_file,
'f|format=s' => \(my $format = 'ansi'),
'h|help' => sub { pod2usage(1) },
'v|version' => sub { print "grok $VERSION\n"; exit },
) or pod2usage();

if (!defined $from_file) {
die "You must supply --file with an argument; see --help\n";
}

if ($format ne 'text' && $format ne 'ansi') {
die "Format '$format' is unsupported\n";
}

if ($format eq 'text') {
require Perl6::Perldoc::To::Text;
}
else {
require Perl6::Perldoc::To::Ansi;
}

print Perl6::Perldoc::Parser->parse($from_file, {all_pod=>'auto'})
->report_errors()
->to_text();
use App::Grok;
App::Grok->run();

=head1 NAME
Expand Down

0 comments on commit 3850bd8

Please sign in to comment.