| File-Dir-Dumper documentation | Contained in the File-Dir-Dumper distribution. |
File::Dir::Dumper::App - a command line app-implemented as a class to do the dumping.
Version 0.0.7
use File::Dir::Dumper::App;
my $app = File::Dir::Dumper::App->new({argv => \@ARGV});
exit($app->run());
Scans using the @ARGV command line arguments.
Runs the application.
Shlomi Fish, <shlomif@cpan.org>
Please report any bugs or feature requests to bug-file-dir-dumper at rt.cpan.org, or through
the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=File-Dir-Dumper. I will be notified, and then you'll
automatically be notified of progress on your bug as I make changes.
You can find documentation for this module with the perldoc command.
perldoc File::Dir::Dumper
You can also look for information at:
Copyright 2008 Shlomi Fish, all rights reserved.
This program is released under the following license: MIT/X11 Licence.
| File-Dir-Dumper documentation | Contained in the File-Dir-Dumper distribution. |
package File::Dir::Dumper::App; use warnings; use strict; use base 'File::Dir::Dumper::Base'; use Carp; use Getopt::Long qw(GetOptionsFromArray); use Pod::Usage; use File::Dir::Dumper::Scanner; use File::Dir::Dumper::Stream::JSON::Writer; __PACKAGE__->mk_accessors( qw( _out_to_stdout _out_filename _dir_to_dump ) );
our $VERSION = '0.0.7';
sub _init { my $self = shift; my $args = shift; my $argv = $args->{'argv'}; my $output_dest; my ($help, $man); GetOptionsFromArray($argv, "output|o=s" => \$output_dest, 'help|h' => \$help, 'man' => \$man, ); pod2usage(1) if $help; pod2usage(-exitstatus => 0, -verbose => 2) if $man; my $dir_to_dump = shift(@$argv); if (defined($output_dest)) { $self->_out_to_stdout(0); $self->_out_filename($output_dest); } else { $self->_out_to_stdout(1); } $self->_dir_to_dump($dir_to_dump); return; } sub run { my $self = shift; my $out; if ($self->_out_to_stdout()) { open $out, ">&STDOUT"; } else { open $out, ">", $self->_out_filename(); } my $scanner = File::Dir::Dumper::Scanner->new( { dir => $self->_dir_to_dump(), } ); my $writer = File::Dir::Dumper::Stream::JSON::Writer->new( { output => $out, } ); while (defined(my $token = $scanner->fetch())) { $writer->put($token); } $writer->close(); return 0; }
1; # End of File::Dir::Dumper