The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Ado::Command - Ado namespace for Mojo commands!

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.

ATTRIBUTES

Ado::Command inherits all attributes from Mojolicious::Command and implements the following new ones.

args

Returns a hash-reference containing all arguments passed to the command on the command-line or to the method "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 Mojolicious::Commands. So, do not use them in your commands and consider them reserved. The known options are 'home=s' and 'm|mode=s'. Ado::Command::generate::apache2htaccess worked around this limitation by using upper case for a short variant of its options - 'M|modules=s@'.

name

The name of your command - (ref $self) =~ /(\w+)$/;.

home

Returns current Ado::Command::foo home.

METHODS

Ado::Command inherits all methods from Mojolicious::Command and implements the following new ones.

init

Should be implemented by the inheriting command.

Should get options from the commandline and populate $self->args. Must return $self.

run

A default $command->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 --do commands line argument and executed. Dies with an error message advising you to implement the subcommand if it is not found in $self->config->{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' );

config

Returns the configuration portion specific for a command.

    #Somewhere in Ado::Command::alabala
    $self->config('username')
    #Same as $self->app->config('alabala')->{username}

SUBCOMANDS

Subcommands shared by all command classes inheriting this class.

...

SEE ALSO

Ado::Command::adduser, Ado::Command::generate, Ado::Command::version

AUTHOR

Красимир Беров (Krasimir Berov)

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.