.\" Automatically generated by Pod::Man 4.10 (Pod::Simple 3.35) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" ======================================================================== .\" .IX Title "MooX::Cmd::Role 3pm" .TH MooX::Cmd::Role 3pm "2019-02-20" "perl v5.28.1" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" MooX::Cmd::Role \- MooX cli app commands do this .SH "SYNOPSIS" .IX Header "SYNOPSIS" .SS "using role and want behavior as MooX::Cmd" .IX Subsection "using role and want behavior as MooX::Cmd" .Vb 1 \& package MyFoo; \& \& with MooX::Cmd::Role; \& \& sub _build_command_execute_from_new { 1 } \& \& package main; \& \& my $cmd = MyFoo\->new_with_cmd; .Ve .SS "using role and don't execute immediately" .IX Subsection "using role and don't execute immediately" .Vb 1 \& package MyFoo; \& \& with MooX::Cmd::Role; \& use List::MoreUtils qw/ first_idx /; \& \& sub _build_command_base { "MyFoo::Command" } \& \& sub _build_command_execute_from_new { 0 } \& \& sub execute { \& my $self = shift; \& my $chain_idx = first_idx { $self == $_ } @{$self\->command_chain}; \& my $next_cmd = $self\->command_chain\->{$chain_idx+1}; \& $next_cmd\->owner($self); \& $next_cmd\->execute; \& } \& \& package main; \& \& my $cmd = MyFoo\->new_with_cmd; \& $cmd\->command_chain\->[\-1]\->run(); .Ve .SS "explicit expression of some implicit stuff" .IX Subsection "explicit expression of some implicit stuff" .Vb 1 \& package MyFoo; \& \& with MooX::Cmd::Role; \& \& sub _build_command_base { "MyFoo::Command" } \& \& sub _build_command_execute_method_name { "run" } \& \& sub _build_command_execute_from_new { 0 } \& \& package main; \& \& my $cmd = MyFoo\->new_with_cmd; \& $cmd\->command_chain\->[\-1]\->run(); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" MooX::Cmd::Role is made for modern, flexible Moo style to tailor cli commands. .SH "ATTRIBUTES" .IX Header "ATTRIBUTES" .SS "command_args" .IX Subsection "command_args" ARRAY-REF of args on command line .SS "command_chain" .IX Subsection "command_chain" ARRAY-REF of commands lead to this instance .SS "command_chain_end" .IX Subsection "command_chain_end" \&\s-1COMMAND\s0 accesses the finally detected command in chain .SS "command_name" .IX Subsection "command_name" ARRAY-REF the name of the command lead to this command .SS "command_commands" .IX Subsection "command_commands" HASH-REF names of other commands .SS "command_base" .IX Subsection "command_base" \&\s-1STRING\s0 base of command plugins .SS "command_execute_method_name" .IX Subsection "command_execute_method_name" \&\s-1STRING\s0 name of the method to invoke to execute a command, default \*(L"execute\*(R" .SS "command_execute_return_method_name" .IX Subsection "command_execute_return_method_name" \&\s-1STRING I\s0 have no clue what that is good for ... .SS "command_creation_method_name" .IX Subsection "command_creation_method_name" \&\s-1STRING\s0 name of constructor .SS "command_creation_chain_methods" .IX Subsection "command_creation_chain_methods" ARRAY-REF names of methods to chain for creating object (from \*(L"command_creation_method_name\*(R") .SS "command_execute_from_new" .IX Subsection "command_execute_from_new" \&\s-1BOOL\s0 true when constructor shall invoke \*(L"command_execute_method_name\*(R", false otherwise .SH "METHODS" .IX Header "METHODS" .SS "new_with_cmd" .IX Subsection "new_with_cmd" initializes by searching command line args for commands and invoke them .SS "execute_return" .IX Subsection "execute_return" returns the content of \f(CW$self\fR\->{execute_return} .SH "LICENSE AND COPYRIGHT" .IX Header "LICENSE AND COPYRIGHT" Copyright 2012\-2013 Torsten Raudssus, Copyright 2013\-2017 Jens Rehsack. .PP This program is free software; you can redistribute it and/or modify it under the terms of either: the \s-1GNU\s0 General Public License as published by the Free Software Foundation; or the Artistic License. .PP See for more information.