MooX::Commander::HasSubcommands - Moo role to add subcommands to your command line app
# inside lib/PieFactory/Cmd/Recipes.pm: package PieFactory::Cmd::Recipes; use Moo; with 'MooX::Commander::HasSubcommands'; usage { return <<EOF Subcommands for: piefactory recipes piefactory recipe list List pie recipes piefactory recipe add <recipe> Display a recipe piefactory recipe delete <recipe> Add a recipe piefactory recipe show <recipe> Delete a recipe EOF } # Create these classes the same way you would build any command class. # For details see MooX::Commander and MooX::Commander::HasOptions. # lib/PieFactory/Cmd/Recipes/List.pm # lib/PieFactory/Cmd/Recipes/Show.pm # lib/PieFactory/Cmd/Recipes/Add.pm # lib/PieFactory/Cmd/Recipes/Delete.pm
MooX::Commander::HasSubcommands is a simple Moo::Role thats subcommands to your command line application. You can also create sub-subcommands and sub-sub-subcommands, etc.
It loads and instantiates the subcommand class the user requested calls the go() method on that object. usage() works the same way here as it does in MooX::Commander::HasOptions -- it prints the usage statement and exits the program unsuccessfuly.
go()
usage()
Copyright (C) Eric Johnson.
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
Eric Johnson <eric.git@iijo.org>
To install MooX::Commander, copy and paste the appropriate command in to your terminal.
cpanm
cpanm MooX::Commander
CPAN shell
perl -MCPAN -e shell install MooX::Commander
For more information on module installation, please visit the detailed CPAN module installation guide.