Created
April 13, 2010 01:04
-
-
Save genehack/364203 to your computer and use it in GitHub Desktop.
A MooseX::App::Cmd command class written with MooseX::Declare
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
use MooseX::Declare; | |
class App::Booklist::CLI::Command::add_tag extends App::Booklist::CLI::BASE { | |
use 5.010; | |
has name => ( | |
isa => 'Str' , is => 'rw' , | |
documentation => 'Tag name' , | |
traits => [ qw(Getopt)] , | |
cmd_aliases => 'n' , | |
required => 1 , | |
); | |
method execute ( $opt , $args ) { | |
my $schema = $self->get_schema_and_deploy_db_if_needed(); | |
my $tag = $schema->resultset('Tags')->find_or_create({ | |
name => $self->name , | |
}); | |
printf "Added tag '%s' (ID=%d)\n" , | |
$tag->name , $tag->id; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment