Ado
view release on metacpan or search on metacpan
lib/Ado/Command.pm view on Meta::CPAN
=pod
=encoding utf8
=head1 NAME
Ado::Command - Ado namespace for Mojo commands!
=head1 DESCRIPTION
Ado::Command is the base class for eventual functionality that we
can run directly from the commandline or from controllers.
In this class we can put common functionality shared among all the commands.
=head1 ATTRIBUTES
L<Ado::Command> inherits all attributes from L<Mojolicious::Command> and implements the following new ones.
=head2 args
Returns a hash-reference containing all arguments passed to the command
on the command-line or to the method L</run>.
The keys are the long variants of the possible commandline arguments
altough you may have used short variants.
#if you passed -s or --something
$self->args->{something} #foo
Also, please note that some options turn out to be "eaten-up" by
L<Mojolicious::Commands>. So, do not use them in your commands and consider them
reserved. The known options are 'C<home=s>' and 'C<m|mode=s>'.
L<Ado::Command::generate::apache2htaccess> worked around this limitation by using
upper case for a short variant of its options - 'C<M|modules=s@>'.
=head2 name
The name of your command - C<(ref $self) =~ /(\w+)$/;>.
=head2 home
Returns current Ado::Command::foo home.
=head1 METHODS
L<Ado::Command> inherits all methods from L<Mojolicious::Command> and implements the following new ones.
=head2 init
Should be implemented by the inheriting command.
Should get options from the commandline and populate C<$self-E<gt>args>.
Must return C<$self>.
=head2 run
A default C<$command-E<gt>run(@args)> method for all Ado::Command commands.
This is the entry point to your mini application.
Looks for subcommands/actions which are looked up in
the C<--do> commands line argument and executed.
Dies with an error message advising you to implement the subcommand
if it is not found in C<$self-E<gt>config-E<gt>{actions}>.
Override it if you want specific behavior.
# as bin/ado alabala --do action --param1 value
Ado::Command::alabala->run(@ARGV);
#or from a controller
Ado::Command::alabala->run(
--do => action => --param1 => 'value' );
=head2 config
Returns the configuration portion specific for a command.
#Somewhere in Ado::Command::alabala
$self->config('username')
#Same as $self->app->config('alabala')->{username}
=head1 SUBCOMANDS
Subcommands shared by all command classes inheriting this class.
...
=head1 SEE ALSO
L<Ado::Command::adduser>, L<Ado::Command::generate>, L<Ado::Command::version>
=head1 AUTHOR
ÐÑаÑÐ¸Ð¼Ð¸Ñ ÐеÑов (Krasimir Berov)
=head1 COPYRIGHT AND LICENSE
Copyright 2013-2014 ÐÑаÑÐ¸Ð¼Ð¸Ñ ÐеÑов (Krasimir Berov).
This program is free software, you can redistribute it and/or
modify it under the terms of the
GNU Lesser General Public License v3 (LGPL-3.0).
You may copy, distribute and modify the software provided that
modifications are open source. However, software that includes
the license may release under a different license.
See http://opensource.org/licenses/lgpl-3.0.html for more information.
=cut
( run in 1.219 second using v1.01-cache-2.11-cpan-2398b32b56e )