App-Gimei

 view release on metacpan or  search on metacpan

lib/App/Gimei/Runner.pm  view on Meta::CPAN

use v5.40;
use feature 'class';
no warnings 'experimental::class';

class App::Gimei::Runner {

    binmode STDOUT, ":encoding(UTF-8)";

    use Getopt::Long;
    use Pod::Usage;
    use Pod::Find qw( pod_where );

    use App::Gimei;
    use App::Gimei::Parser;

    #
    # instance variables
    #

    field $conf : param = { POD_FILE => pod_where( { -inc => 1 }, 'App::Gimei' ) };

    #
    # instance methods
    #

    method _parse_option ( $args_ref, $opts_ref ) {
        $opts_ref->{n}   = 1;
        $opts_ref->{sep} = ', ';

        my $p = Getopt::Long::Parser->new( config => ["no_ignore_case"], );

        local $SIG{__WARN__} = sub { die "Error: $_[0]" };
        my $ok =
          $p->getoptionsfromarray( $args_ref, $opts_ref, "help|h", "version|v", "n=i",
            "sep=s", );

        if ( $opts_ref->{n} < 1 ) {
            die
"Error: value $opts_ref->{n} invalid for option n (must be positive number)\n";
        }
    }

    method execute (@args) {
        my %opts;
        $self->_parse_option( \@args, \%opts );

        if ( $opts{version} ) {
            say "$App::Gimei::VERSION";
            return 0;
        }

        if ( $opts{help} ) {
            pod2usage( -input => ${$conf}{POD_FILE}, -exitval => 'noexit' );
            return 0;
        }

        if ( !@args ) {
            push @args, 'name:kanji';
        }

        #        my $parser     = App::Gimei::Parser->new( args => \@args );
        #        my $generators = $parser->parse();
        my $generators = App::Gimei::Parser::parse( \@args );

        _semantic_analysis($generators);

        foreach ( 1 .. $opts{n} ) {



( run in 0.695 second using v1.01-cache-2.11-cpan-ceb78f64989 )