#!perl
use strict;
use warnings FATAL => 'all';
use MarpaX::Java::ClassFile;
use Data::Scan::Printer;
use POSIX qw/EXIT_SUCCESS EXIT_FAILURE/;
use Log::Log4perl qw/:easy/;
use Log::Any::Adapter;
use Log::Any qw/$log/;
#
# Init log
#
our $defaultLog4perlConf = '
log4perl.rootLogger              = WARN, Screen
log4perl.appender.Screen         = Log::Log4perl::Appender::Screen
log4perl.appender.Screen.stderr  = 0
log4perl.appender.Screen.layout  = PatternLayout
log4perl.appender.Screen.layout.ConversionPattern = %d %-5p %6P %m{chomp}%n
';
Log::Log4perl::init(\$defaultLog4perlConf);
Log::Any::Adapter->set('Log4perl');

# PODNAME: javapp

# ABSTRACT: javap writen in perl

our $VERSION = '0.001'; # TRIAL VERSION

our $AUTHORITY = 'cpan:JDDPAUSE'; # AUTHORITY

my $file = shift || '';
if (! $file) {
  print STDERR "Usage: $0 classFile\n";
  exit(EXIT_FAILURE);
}
open(my $fh, '<', $file) || die "Cannot open $file, $!";
binmode($fh);
my $input = do { local $/; <$fh>};
close($fh) || warn "Cannot close $file, $!";
dspp(MarpaX::Java::ClassFile->new(input => $input)->ast);

exit(EXIT_SUCCESS);

__END__

=pod

=encoding UTF-8

=head1 NAME

javapp - javap writen in perl

=head1 VERSION

version 0.001

=head1 AUTHOR

Jean-Damien Durand <jeandamiendurand@free.fr>

=head1 COPYRIGHT AND LICENSE

This software is copyright (c) 2015 by Jean-Damien Durand.

This is free software; you can redistribute it and/or modify it under
the same terms as the Perl 5 programming language system itself.

=cut
