GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
MooX::Cmd::Role(3) User Contributed Perl Documentation MooX::Cmd::Role(3)

MooX::Cmd::Role - MooX cli app commands do this

  package MyFoo;
  
  with MooX::Cmd::Role;
  
  sub _build_command_execute_from_new { 1 }

  package main;

  my $cmd = MyFoo->new_with_cmd;

  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();

  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();

MooX::Cmd::Role is made for modern, flexible Moo style to tailor cli commands.

ARRAY-REF of args on command line

ARRAY-REF of commands lead to this instance

COMMAND accesses the finally detected command in chain

ARRAY-REF the name of the command lead to this command

HASH-REF names of other commands

STRING base of command plugins

STRING name of the method to invoke to execute a command, default "execute"

STRING I have no clue what that is good for ...

STRING name of constructor

ARRAY-REF names of methods to chain for creating object (from "command_creation_method_name")

BOOL true when constructor shall invoke "command_execute_method_name", false otherwise

initializes by searching command line args for commands and invoke them

returns the content of $self->{execute_return}

Copyright 2012-2013 Torsten Raudssus, Copyright 2013-2017 Jens Rehsack.

This program is free software; you can redistribute it and/or modify it under the terms of either: the GNU General Public License as published by the Free Software Foundation; or the Artistic License.

See <http://dev.perl.org/licenses/> for more information.

2017-12-19 perl v5.32.1

Search for    or go to Top of page |  Section 3 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.