Last active
October 3, 2017 07:18
-
-
Save nisei/3ce2caf2e1b77d1c2f77 to your computer and use it in GitHub Desktop.
CLI for Mojolicious
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package Test::Web::CLI::Base; | |
use Mojo::Base qw/Mojolicious::Command/; | |
# public processing for CLI | |
sub get_data { | |
my $self = shift; | |
return 'data'; | |
} | |
1; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env perl | |
use strict; | |
use warnings; | |
use FindBin; | |
BEGIN { | |
unshift @INC, "$FindBin::Bin/../lib"; | |
$ENV{MOJO_HOME} = "$FindBin::Bin/../"; | |
} | |
use Mojolicious::Commands; | |
my $cmd = Mojolicious::Commands->new; | |
$cmd->namespaces([qw/Test::Web::CLI/]); | |
$cmd->run(@ARGV); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package Test::Web::CLI::Testcli; | |
use Mojo::Base qw/Test::Web::CLI::Base/; | |
# Testcli command processing | |
# package name | |
sub run { | |
my ($self, @args) = @_; | |
my $data = $self->get_data; | |
print $args[0].$data; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ perl cli.pl Testcli test | |
datatest |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment