1#!/usr/local/bin/perl 2use strict; 3use warnings; 4use FindBin; 5use Getopt::Long; 6use Pod::Usage; 7use lib(File::Spec->catdir($FindBin::Bin, File::Spec->updir, 'lib')); 8 9use Gungho; 10 11{ 12 my ($config, $version, $help); 13 14 # Default config file is expected to be at the current directory 15 $config = do { 16 my $file; 17 foreach my $suffix qw(yml yaml) { 18 my $test = "config.$suffix"; 19 if (-f $test) { 20 $file = $test; 21 last; 22 } 23 } 24 $file; 25 }; 26 27 if (! GetOptions( 28 '--config=s', => \$config, 29 '--version!', => \$version, 30 '--help!' => \$help 31 )) { 32 exit 1; 33 } 34 35 if ($version) { 36 print <<EOM; 37gungho - An Extensible, High-Performance Web Crawler Framework 38version: $Gungho::VERSION 39EOM 40 exit 0; 41 } 42 43 if ($help) { 44 pod2usage(-verbose => 2); 45 } 46 47 if (! $config) { 48 pod2usage(-verbose => 0); 49 } 50 51 Gungho->run($config); 52} 53 54__END__ 55 56=head1 NAME 57 58gungho - An Extensible, High-Performance Web Crawler Framework 59 60=head1 SYNOPSIS 61 62 gungho -c config.yml 63 gungho -v 64 gungho -h 65 66=head1 DESCRIPTION 67 68gungho is the command line tool to run the Gungho web crawler framework. 69 70=head1 OPTIONS 71 72=head2 --config | -c 73 74Specify the config file to read from. By default, gungho attempts to read 75a config file named config.yml in the current directory 76 77=head2 --version | -v 78 79Print out the version and exit 80 81=head2 --help | -h 82 83Print out this help message and exit 84 85=head1 AUTHOR 86 87Gungho is Copyright (c) 2007 Daisuke Maki <daisuke@endeworks.jp> Endeworks Ltd. 88All rights reserved. 89 90=head1 LICENSE 91 92This program is free software; you can redistribute it and/or modify it 93under the same terms as Perl itself. 94 95See http://www.perl.com/perl/misc/Artistic.html 96 97=cut 98