MooX-Cmd-1.000000755001750001750 015150637252 12556 5ustar00gettygetty000000000000README100644001750001750 61515150637252 13501 0ustar00gettygetty000000000000MooX-Cmd-1.000This archive contains the distribution MooX-Cmd, version 1.000: Giving an easy Moo style way to make command organized CLI apps This software is copyright (c) 2026 by Torsten Raudssus. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. This README file was generated by Dist::Zilla::Plugin::Readme v6.032. Changes100644001750001750 1063515150637252 14157 0ustar00gettygetty000000000000MooX-Cmd-1.0001.000 2026-02-28 19:14:47Z - Switch to Dist::Zilla with @Author::GETTY plugin bundle 0.017 2017-12-19 - bump author requirement for proper Perl::Tidy to 20171214 - ensure only MooX::Options 4.100 is tested to avoid false regressions 0.016_001 2017-12-12 - improve repository infrastructure (steal from MooX::Options) - fix cmd plugin loader to ensure unambiguous commands - introduce optional role allowing abbreviated commands on CLI 0.015 2015-05-29 - fix breaking tests on Win32 due stacked Capture::Tiny::_capture_tee (thanks Alexandr Ciornii for reporting) 0.014 2015-05-27 - switching from IO::TieCombine to stacked Capture::Tiny in MooX::Cmd::Tester to avoid breaking commands in test (only) when relying on fileno of STD{OUT,ERR} 0.013 2015-03-04 - fix repository path's (reported by haarg) - fix ConfigFromFile test for Moose 0.012 2015-03-03 - add support for MooX::ConfigFromFile (0.006+) - improve initialization by using List::MoreUtils combo-functions instead of puzzling with List::Util - improve test coverage 0.011 2014-12-03 - apply clean Perl::Tidy rules to avoid mixed spaces/tabs and other settings - add version number to MooX::Cmd::Tester - allow overriding protected constructor when renaming public one 0.010 2014-12-02 - switch distribution tooling from Dist::Zilla to ExtUtils::MakeMaker - Added Changes file with content based on git log according to CPAN::Changes::Spec (Neil Bowers) - Apply typo fixes for documentation from David Steinbrunner - Sven Schober provided heavily improved description 0.009 2014-02-08 - Apply submitted fix for RT#91481 - without test .. - fix RT#91500 - incorrect execute_return if ... The implication was wrong, indeed - but the effort was increadible. Testing sucks :P - distinguish between test_cmd and test_cmd_ok - after chained constructor, we can use getters - add missing prereqs 0.008 2013-11-13 - groundwork for testing with Mo(o(se)) - add THANKS section - final test for MooX::Options 3.99 - eliminate hidden/private __moox_cmd_chain param - massively increase test coverage 0.007 2013-11-07 - improve test coverage of MooX::Cmd::Role - 100% test coverage of MooX::Cmd - add some documentation for MooX::Cmd::Tester - ignore editor temp files and backup files - enhance and fix tests - Adopt basic tests using tester API - steal some code from App::Cmd::Tester and adopt Basic test infrastructure ... needs fine tuning, but first steps are done that way. - BAIL_OUT when unable to load MooX::Cmd No further testing possible nor reasonable 0.006001 2013-11-06 - remove superfluous "my" causing undef command_name 0.006 2013-11-05 - Merge github.com:rehsack/MooX-Cmd 0.005 2013-11-05 - Merge github.com:Getty/p5-moox-cmd into rehsack - correct content of command_name attribute - Merge github.com:Getty/p5-moox-cmd 0.004 2013-11-02 - New travis config - Add some comfort as primary author desires To avoid scaring users the Getty wants some improved examples and an accessor for last cmd in chain. - Add some samples to role author wants ('examples') x INT_MAX - unfortunately he gets only one - Move initialization to MooX::Cmd::Role - Improve documentation - Allow Class->new_with_cmd->execute(...) - Move initialization sequence for cmd into role As discussed with primary author, a role having all neat information about the cmd state in attributes is smarter that passing arguments ... - Simplify loading commands to avoid stack frames - Remove trailing \t - Some safety first checks and minor optimizations - Allow commands show available neighbours/children - Merge github.com:Getty/p5-moox-cmd - Merge pull request #2 from yanick/master only load commands if used - Bump Module::Pluggable version to stop 5.18 from whining and let it work smoothly on blead 0.003 2013-04-20 - Switched to Author::GETTY, added .travis.yml - Don't load commands unless they are used This should make things much more zippy if we have more than a handful of commands. 0.002 2012-05-07 - Added requirement for Package::Stash - Added documentation (hope it works ;) as told hehe) and use of Package::Stash 0.001 2012-02-10 - First release to CPAN LICENSE100644001750001750 4631515150637252 13675 0ustar00gettygetty000000000000MooX-Cmd-1.000This software is copyright (c) 2026 by Torsten Raudssus. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. Terms of the Perl programming language system itself a) the GNU General Public License as published by the Free Software Foundation; either version 1, or (at your option) any later version, or b) the "Artistic License" --- The GNU General Public License, Version 1, February 1989 --- This software is Copyright (c) 2026 by Torsten Raudssus. This is free software, licensed under: The GNU General Public License, Version 1, February 1989 GNU GENERAL PUBLIC LICENSE Version 1, February 1989 Copyright (C) 1989 Free Software Foundation, Inc. Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The license agreements of most software companies try to keep users at the mercy of those companies. By contrast, our General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. The General Public License applies to the Free Software Foundation's software and to any other program whose authors commit to using it. You can use it for your programs, too. When we speak of free software, we are referring to freedom, not price. Specifically, the General Public License is designed to make sure that you have the freedom to give away or sell copies of free software, that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of a such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must tell them their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. The precise terms and conditions for copying, distribution and modification follow. GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License Agreement applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any work containing the Program or a portion of it, either verbatim or with modifications. Each licensee is addressed as "you". 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this General Public License and to the absence of any warranty; and give any other recipients of the Program a copy of this General Public License along with the Program. You may charge a fee for the physical act of transferring a copy. 2. You may modify your copy or copies of the Program or any portion of it, and copy and distribute such modifications under the terms of Paragraph 1 above, provided that you also do the following: a) cause the modified files to carry prominent notices stating that you changed the files and the date of any change; and b) cause the whole of any work that you distribute or publish, that in whole or in part contains the Program or any part thereof, either with or without modifications, to be licensed at no charge to all third parties under the terms of this General Public License (except that you may choose to grant warranty protection to some or all third parties, at your option). c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the simplest and most usual way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this General Public License. d) You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. Mere aggregation of another independent work with the Program (or its derivative) on a volume of a storage or distribution medium does not bring the other work under the scope of these terms. 3. You may copy and distribute the Program (or a portion or derivative of it, under Paragraph 2) in object code or executable form under the terms of Paragraphs 1 and 2 above provided that you also do one of the following: a) accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Paragraphs 1 and 2 above; or, b) accompany it with a written offer, valid for at least three years, to give any third party free (except for a nominal charge for the cost of distribution) a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Paragraphs 1 and 2 above; or, c) accompany it with the information you received as to where the corresponding source code may be obtained. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form alone.) Source code for a work means the preferred form of the work for making modifications to it. For an executable file, complete source code means all the source code for all modules it contains; but, as a special exception, it need not include source code for modules which are standard libraries that accompany the operating system on which the executable file runs, or for standard header files or definitions files that accompany that operating system. 4. You may not copy, modify, sublicense, distribute or transfer the Program except as expressly provided under this General Public License. Any attempt otherwise to copy, modify, sublicense, distribute or transfer the Program is void, and will automatically terminate your rights to use the Program under this License. However, parties who have received copies, or rights to use copies, from you under this General Public License will not have their licenses terminated so long as such parties remain in full compliance. 5. By copying, distributing or modifying the Program (or any work based on the Program) you indicate your acceptance of this license to do so, and all its terms and conditions. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. 7. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies a version number of the license which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of the license, you may choose any version ever published by the Free Software Foundation. 8. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 9. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 10. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS Appendix: How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to humanity, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) 19yy This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 1, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, see . Also add information on how to contact you by electronic and paper mail. If the program is interactive, make it output a short notice like this when it starts in an interactive mode: Gnomovision version 69, Copyright (C) 19xx name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than `show w' and `show c'; they could even be mouse-clicks or menu items--whatever suits your program. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision' (a program to direct compilers to make passes at assemblers) written by James Hacker. , 1 April 1989 Moe Ghoul, President of Vice That's all there is to it! --- The Perl Artistic License 1.0 --- This software is Copyright (c) 2026 by Torsten Raudssus. This is free software, licensed under: The Perl Artistic License 1.0 The "Artistic License" Preamble The intent of this document is to state the conditions under which a Package may be copied, such that the Copyright Holder maintains some semblance of artistic control over the development of the package, while giving the users of the package the right to use and distribute the Package in a more-or-less customary fashion, plus the right to make reasonable modifications. Definitions: "Package" refers to the collection of files distributed by the Copyright Holder, and derivatives of that collection of files created through textual modification. "Standard Version" refers to such a Package if it has not been modified, or has been modified in accordance with the wishes of the Copyright Holder as specified below. "Copyright Holder" is whoever is named in the copyright or copyrights for the package. "You" is you, if you're thinking about copying or distributing this Package. "Reasonable copying fee" is whatever you can justify on the basis of media cost, duplication charges, time of people involved, and so on. (You will not be required to justify it to the Copyright Holder, but only to the computing community at large as a market that must bear the fee.) "Freely Available" means that no fee is charged for the item itself, though there may be fees involved in handling the item. It also means that recipients of the item may redistribute it under the same conditions they received it. 1. You may make and give away verbatim copies of the source form of the Standard Version of this Package without restriction, provided that you duplicate all of the original copyright notices and associated disclaimers. 2. You may apply bug fixes, portability fixes and other modifications derived from the Public Domain or from the Copyright Holder. A Package modified in such a way shall still be considered the Standard Version. 3. You may otherwise modify your copy of this Package in any way, provided that you insert a prominent notice in each changed file stating how and when you changed that file, and provided that you do at least ONE of the following: a) place your modifications in the Public Domain or otherwise make them Freely Available, such as by posting said modifications to Usenet or an equivalent medium, or placing the modifications on a major archive site such as uunet.uu.net, or by allowing the Copyright Holder to include your modifications in the Standard Version of the Package. b) use the modified Package only within your corporation or organization. c) rename any non-standard executables so the names do not conflict with standard executables, which must also be provided, and provide a separate manual page for each non-standard executable that clearly documents how it differs from the Standard Version. d) make other distribution arrangements with the Copyright Holder. 4. You may distribute the programs of this Package in object code or executable form, provided that you do at least ONE of the following: a) distribute a Standard Version of the executables and library files, together with instructions (in the manual page or equivalent) on where to get the Standard Version. b) accompany the distribution with the machine-readable source of the Package with your modifications. c) give non-standard executables non-standard names, and clearly document the differences in manual pages (or equivalent), together with instructions on where to get the Standard Version. d) make other distribution arrangements with the Copyright Holder. 5. You may charge a reasonable copying fee for any distribution of this Package. You may charge any fee you choose for support of this Package. You may not charge a fee for this Package itself. However, you may distribute this Package in aggregate with other (possibly commercial) programs as part of a larger (possibly commercial) software distribution provided that you do not advertise this Package as a product of your own. You may embed this Package's interpreter within an executable of yours (by linking); this shall be construed as a mere form of aggregation, provided that the complete Standard Version of the interpreter is so embedded. 6. The scripts and library files supplied as input to or produced as output from the programs of this Package do not automatically fall under the copyright of this Package, but belong to whoever generated them, and may be sold commercially, and may be aggregated with this Package. If such scripts or library files are aggregated with this Package via the so-called "undump" or "unexec" methods of producing a binary executable image, then distribution of such an image shall neither be construed as a distribution of this Package nor shall it fall under the restrictions of Paragraphs 3 and 4, provided that you do not represent such an executable image as a Standard Version of this Package. 7. C subroutines (or comparably compiled subroutines in other languages) supplied by you and linked into this Package in order to emulate subroutines and variables of the language defined by this Package shall not be considered part of this Package, but are the equivalent of input as in Paragraph 6, provided these subroutines do not change the language in any way that would cause it to fail the regression tests for the language. 8. Aggregation of this Package with a commercial distribution is always permitted provided that the use of this Package is embedded; that is, when no overt attempt is made to make this Package's interfaces visible to the end user of the commercial distribution. Such use shall not be construed as a distribution of this Package. 9. The name of the Copyright Holder may not be used to endorse or promote products derived from this software without specific prior written permission. 10. THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. The End cpanfile100644001750001750 144615150637252 14350 0ustar00gettygetty000000000000MooX-Cmd-1.000requires 'Carp'; requires 'List::MoreUtils', '0.406'; requires 'Moo', '0.009013'; requires 'Module::Pluggable', '4.8'; requires 'Module::Runtime'; requires 'Package::Stash', '0.33'; requires 'Params::Util', '0.37'; requires 'Regexp::Common', '2011121001'; requires 'Scalar::Util'; requires 'Text::ParseWords'; recommends 'Hash::Merge', '0.299'; recommends 'MooX::ConfigFromFile', '0.008'; recommends 'Text::Abbrev'; on test => sub { requires 'Test::More', '0.98'; requires 'Capture::Tiny'; }; on develop => sub { requires 'Test::CPAN::Changes'; requires 'Test::Kwalitee'; requires 'Test::Perl::Critic'; requires 'Test::PerlTidy'; requires 'Test::Pod::Coverage'; requires 'Test::Pod::Spelling::CommonMistakes'; requires 'Test::Spelling'; }; dist.ini100644001750001750 23115150637252 14257 0ustar00gettygetty000000000000MooX-Cmd-1.000name = MooX-Cmd author = Torsten Raudssus license = Perl_5 copyright_holder = Torsten Raudssus [@Author::GETTY] irc = #web-simple META.yml100644001750001750 2752315150637252 14141 0ustar00gettygetty000000000000MooX-Cmd-1.000--- abstract: 'Giving an easy Moo style way to make command organized CLI apps' author: - 'Torsten Raudssus ' build_requires: Capture::Tiny: '0' Test::More: '0.98' configure_requires: ExtUtils::MakeMaker: '0' dynamic_config: 0 generated_by: 'Dist::Zilla version 6.032, CPAN::Meta::Converter version 2.150010' license: perl meta-spec: url: http://module-build.sourceforge.net/META-spec-v1.4.html version: '1.4' name: MooX-Cmd recommends: Hash::Merge: '0.299' MooX::ConfigFromFile: '0.008' Text::Abbrev: '0' requires: Carp: '0' List::MoreUtils: '0.406' Module::Pluggable: '4.8' Module::Runtime: '0' Moo: '0.009013' Package::Stash: '0.33' Params::Util: '0.37' Regexp::Common: '2011121001' Scalar::Util: '0' Text::ParseWords: '0' resources: IRC: irc://irc.perl.org/#web-simple IRC_user: Getty bugtracker: https://github.com/Getty/p5-moox-cmd/issues homepage: https://github.com/Getty/p5-moox-cmd repository: https://github.com/Getty/p5-moox-cmd.git version: '1.000' x_Dist_Zilla: perl: version: '5.036000' plugins: - class: Dist::Zilla::Plugin::Git::GatherDir config: Dist::Zilla::Plugin::GatherDir: exclude_filename: [] exclude_match: [] include_dotfiles: 1 prefix: '' prune_directory: [] root: . Dist::Zilla::Plugin::Git::GatherDir: include_untracked: 0 name: '@Author::GETTY/Git::GatherDir' version: '2.052' - class: Dist::Zilla::Plugin::ManifestSkip name: '@Author::GETTY/@Filter/ManifestSkip' version: '6.032' - class: Dist::Zilla::Plugin::MetaYAML name: '@Author::GETTY/@Filter/MetaYAML' version: '6.032' - class: Dist::Zilla::Plugin::License name: '@Author::GETTY/@Filter/License' version: '6.032' - class: Dist::Zilla::Plugin::Readme name: '@Author::GETTY/@Filter/Readme' version: '6.032' - class: Dist::Zilla::Plugin::ExtraTests name: '@Author::GETTY/@Filter/ExtraTests' version: '6.032' - class: Dist::Zilla::Plugin::ExecDir name: '@Author::GETTY/@Filter/ExecDir' version: '6.032' - class: Dist::Zilla::Plugin::ShareDir name: '@Author::GETTY/@Filter/ShareDir' version: '6.032' - class: Dist::Zilla::Plugin::MakeMaker config: Dist::Zilla::Role::TestRunner: default_jobs: 1 name: '@Author::GETTY/@Filter/MakeMaker' version: '6.032' - class: Dist::Zilla::Plugin::Manifest name: '@Author::GETTY/@Filter/Manifest' version: '6.032' - class: Dist::Zilla::Plugin::TestRelease name: '@Author::GETTY/@Filter/TestRelease' version: '6.032' - class: Dist::Zilla::Plugin::ConfirmRelease name: '@Author::GETTY/@Filter/ConfirmRelease' version: '6.032' - class: Dist::Zilla::Plugin::UploadToCPAN name: '@Author::GETTY/@Filter/UploadToCPAN' version: '6.032' - class: Dist::Zilla::Plugin::MetaConfig name: '@Author::GETTY/MetaConfig' version: '6.032' - class: Dist::Zilla::Plugin::MetaJSON name: '@Author::GETTY/MetaJSON' version: '6.032' - class: Dist::Zilla::Plugin::PodSyntaxTests name: '@Author::GETTY/PodSyntaxTests' version: '6.032' - class: Dist::Zilla::Plugin::GithubMeta name: '@Author::GETTY/GithubMeta' version: '0.58' - class: Dist::Zilla::Plugin::MetaResources name: '@Author::GETTY/MetaResources' version: '6.032' - class: Dist::Zilla::Plugin::InstallRelease name: '@Author::GETTY/InstallRelease' version: '0.008' - class: Dist::Zilla::Plugin::Authority name: '@Author::GETTY/Authority' version: '1.009' - class: Dist::Zilla::Plugin::Git::CheckFor::CorrectBranch config: Dist::Zilla::Role::Git::Repo: git_version: 2.39.5 repo_root: . name: '@Author::GETTY/Git::CheckFor::CorrectBranch' version: '0.014' - class: Dist::Zilla::Plugin::Prereqs::FromCPANfile name: '@Author::GETTY/Prereqs::FromCPANfile' version: '0.08' - class: Dist::Zilla::Plugin::PodWeaver config: Dist::Zilla::Plugin::PodWeaver: config_plugins: - '@Author::GETTY' finder: - ':InstallModules' - ':PerlExecFiles' plugins: - class: Pod::Weaver::Plugin::EnsurePod5 name: '@CorePrep/EnsurePod5' version: '4.020' - class: Pod::Weaver::Plugin::H1Nester name: '@CorePrep/H1Nester' version: '4.020' - class: Pod::Weaver::Plugin::SingleEncoding name: '@GETTY/SingleEncoding' version: '4.020' - class: Pod::Weaver::Section::Name name: '@GETTY/Name' version: '4.020' - class: Pod::Weaver::Section::Version name: '@GETTY/Version' version: '4.020' - class: Pod::Weaver::Section::Region name: '@GETTY/Prelude' version: '4.020' - class: Pod::Weaver::Section::Generic name: '@GETTY/Synopsis' version: '4.020' - class: Pod::Weaver::Section::Generic name: '@GETTY/Description' version: '4.020' - class: Pod::Weaver::Section::Generic name: '@GETTY/Overview' version: '4.020' - class: Pod::Weaver::Section::Generic name: '@GETTY/Stability' version: '4.020' - class: Pod::Weaver::Section::Leftovers name: '@GETTY/Leftovers' version: '4.020' - class: Pod::Weaver::Section::Region name: '@GETTY/postlude' version: '4.020' - class: Pod::Weaver::Section::GenerateSection name: '@GETTY/Support' version: '4.020' - class: Pod::Weaver::Section::GenerateSection name: '@GETTY/Contributing' version: '4.020' - class: Pod::Weaver::Section::Authors name: '@GETTY/Authors' version: '4.020' - class: Pod::Weaver::Section::Legal name: '@GETTY/Legal' version: '4.020' - class: Pod::Weaver::Plugin::Transformer name: '@GETTY/List' version: '4.020' - class: Pod::Weaver::Plugin::Transformer name: '@GETTY/GETTY' version: '4.020' name: '@Author::GETTY/PodWeaver' version: '4.010' - class: Dist::Zilla::Plugin::Prereqs config: Dist::Zilla::Plugin::Prereqs: phase: develop type: recommends name: '@Author::GETTY/@Git::VersionManager/pluginbundle version' version: '6.032' - class: Dist::Zilla::Plugin::RewriteVersion::Transitional config: Dist::Zilla::Plugin::RewriteVersion: add_tarball_name: 0 finders: - ':ExecFiles' - ':InstallModules' global: 0 skip_version_provider: 0 Dist::Zilla::Plugin::RewriteVersion::Transitional: {} name: '@Author::GETTY/@Git::VersionManager/RewriteVersion::Transitional' version: '0.009' - class: Dist::Zilla::Plugin::MetaProvides::Update name: '@Author::GETTY/@Git::VersionManager/MetaProvides::Update' version: '0.007' - class: Dist::Zilla::Plugin::CopyFilesFromRelease config: Dist::Zilla::Plugin::CopyFilesFromRelease: filename: - Changes match: [] name: '@Author::GETTY/@Git::VersionManager/CopyFilesFromRelease' version: '0.007' - class: Dist::Zilla::Plugin::Git::Commit config: Dist::Zilla::Plugin::Git::Commit: add_files_in: [] commit_msg: v%V%n%n%c signoff: 0 Dist::Zilla::Role::Git::DirtyFiles: allow_dirty: - Changes allow_dirty_match: [] changelog: Changes Dist::Zilla::Role::Git::Repo: git_version: 2.39.5 repo_root: . Dist::Zilla::Role::Git::StringFormatter: time_zone: local name: '@Author::GETTY/@Git::VersionManager/release snapshot' version: '2.052' - class: Dist::Zilla::Plugin::Git::Tag config: Dist::Zilla::Plugin::Git::Tag: branch: ~ changelog: Changes signed: 0 tag: '1.000' tag_format: '%v' tag_message: v%V Dist::Zilla::Role::Git::Repo: git_version: 2.39.5 repo_root: . Dist::Zilla::Role::Git::StringFormatter: time_zone: local name: '@Author::GETTY/@Git::VersionManager/Git::Tag' version: '2.052' - class: Dist::Zilla::Plugin::BumpVersionAfterRelease::Transitional config: Dist::Zilla::Plugin::BumpVersionAfterRelease: finders: - ':ExecFiles' - ':InstallModules' global: 0 munge_makefile_pl: 1 Dist::Zilla::Plugin::BumpVersionAfterRelease::Transitional: {} name: '@Author::GETTY/@Git::VersionManager/BumpVersionAfterRelease::Transitional' version: '0.009' - class: Dist::Zilla::Plugin::NextRelease name: '@Author::GETTY/@Git::VersionManager/NextRelease' version: '6.032' - class: Dist::Zilla::Plugin::Git::Commit config: Dist::Zilla::Plugin::Git::Commit: add_files_in: [] commit_msg: 'increment $VERSION after %v release' signoff: 0 Dist::Zilla::Role::Git::DirtyFiles: allow_dirty: - Build.PL - Changes - Makefile.PL allow_dirty_match: - (?^:^lib/.*\.pm$) changelog: Changes Dist::Zilla::Role::Git::Repo: git_version: 2.39.5 repo_root: . Dist::Zilla::Role::Git::StringFormatter: time_zone: local name: '@Author::GETTY/@Git::VersionManager/post-release commit' version: '2.052' - class: Dist::Zilla::Plugin::Git::Push config: Dist::Zilla::Plugin::Git::Push: push_to: - origin remotes_must_exist: 1 Dist::Zilla::Role::Git::Repo: git_version: 2.39.5 repo_root: . name: '@Author::GETTY/Git::Push' version: '2.052' - class: Dist::Zilla::Plugin::FinderCode name: ':InstallModules' version: '6.032' - class: Dist::Zilla::Plugin::FinderCode name: ':IncModules' version: '6.032' - class: Dist::Zilla::Plugin::FinderCode name: ':TestFiles' version: '6.032' - class: Dist::Zilla::Plugin::FinderCode name: ':ExtraTestFiles' version: '6.032' - class: Dist::Zilla::Plugin::FinderCode name: ':ExecFiles' version: '6.032' - class: Dist::Zilla::Plugin::FinderCode name: ':PerlExecFiles' version: '6.032' - class: Dist::Zilla::Plugin::FinderCode name: ':ShareFiles' version: '6.032' - class: Dist::Zilla::Plugin::FinderCode name: ':MainModule' version: '6.032' - class: Dist::Zilla::Plugin::FinderCode name: ':AllFiles' version: '6.032' - class: Dist::Zilla::Plugin::FinderCode name: ':NoFiles' version: '6.032' zilla: class: Dist::Zilla::Dist::Builder config: is_trial: 0 version: '6.032' x_authority: cpan:GETTY x_generated_by_perl: v5.36.0 x_serialization_backend: 'YAML::Tiny version 1.74' x_spdx_expression: 'Artistic-1.0-Perl OR GPL-1.0-or-later' MANIFEST100644001750001750 313615150637252 13773 0ustar00gettygetty000000000000MooX-Cmd-1.000# This file was automatically generated by Dist::Zilla::Plugin::Manifest v6.032. .gitignore .perltidyrc Changes LICENSE MANIFEST META.json META.yml Makefile.PL README README.md cpanfile dist.ini etc/04-moox-configfromfile.t-check-it.json etc/04-moox-configfromfile.t-check.json etc/04-moox-configfromfile.t.json etc/06-abbrev-configfromfile.t-thuruksbeard.json etc/06-abbrev-configfromfile.t-thurukspride.json etc/06-abbrev-configfromfile.t.json lib/MooX/Cmd.pm lib/MooX/Cmd/Role.pm lib/MooX/Cmd/Role/AbbrevCmds.pm lib/MooX/Cmd/Role/ConfigFromFile.pm lib/MooX/Cmd/Tester.pm t/00-load.t t/01-simple.t t/02-moox-options.t t/03-params.t t/04-moox-configfromfile.t t/05-text-abbrev.t t/06-abbrev-configfromfile.t t/author-pod-syntax.t t/lib/AbbrevApp.pm t/lib/AbbrevApp/Cmd/ThuruksBeard.pm t/lib/AbbrevApp/Cmd/ThuruksPride.pm t/lib/ConfigAbbrevApp.pm t/lib/ConfigAbbrevApp/Cmd/ThuruksBeard.pm t/lib/ConfigAbbrevApp/Cmd/ThuruksPride.pm t/lib/ConfigApp.pm t/lib/ConfigApp/Cmd/Check.pm t/lib/ConfigApp/Cmd/Check/Cmd/It.pm t/lib/FailTestApp.pm t/lib/FailTestApp/Cmd/nocreatable.pm t/lib/FailTestApp/Cmd/nothing.pm t/lib/FailTestApp/Cmd/uncreatable.pm t/lib/FirstTestApp.pm t/lib/FirstTestApp/Cmd/Test.pm t/lib/FirstTestApp/Cmd/Test/Cmd/Test.pm t/lib/OptionTestApp.pm t/lib/OptionTestApp/Cmd/Oops.pm t/lib/OptionTestApp/Cmd/primary.pm t/lib/OptionTestApp/Cmd/primary/Cmd/secondary.pm t/lib/SecondTestApp.pm t/lib/SecondTestApp/Cmd/cwo.pm t/lib/SecondTestApp/Cmd/ifc.pm t/lib/ThirdTestApp.pm t/lib/ThirdTestApp/Cmd/Foo.pm xt/changes.t xt/kwalitee.t xt/perlcritic.rc xt/perlcritic.t xt/perltidy.t xt/pod-cm.t xt/pod-coverage.t xt/spelling.t README.md100644001750001750 440715150637252 14123 0ustar00gettygetty000000000000MooX-Cmd-1.000# MooX::Cmd **Command-organized CLI apps with Moo** MooX::Cmd makes it easy to build command-line applications with nested subcommands, all using the lightweight [Moo](https://metacpan.org/pod/Moo) OOP framework. Commands form a tree structure mirrored in your package hierarchy -- each command gets its own class, its own options, and its own `execute` method. [![CPAN Version](https://img.shields.io/cpan/v/MooX-Cmd.svg)](https://metacpan.org/pod/MooX::Cmd) ## Quick Start ```perl package MyApp; use Moo; use MooX::Cmd; sub execute { my ($self, $args, $chain) = @_; say "Hello from MyApp!"; } package MyApp::Cmd::greet; use Moo; use MooX::Cmd; sub execute { my ($self, $args, $chain) = @_; say "Hello, @{$args}!"; } package main; MyApp->new_with_cmd; ``` ``` $ myapp greet World Hello, World! ``` ## Features - Nested subcommand trees (`myapp foo bar baz`) - Command chain with full access to parent instances - Integrates seamlessly with [MooX::Options](https://metacpan.org/pod/MooX::Options) for option parsing - Optional [MooX::ConfigFromFile](https://metacpan.org/pod/MooX::ConfigFromFile) support - Optional abbreviated commands via [Text::Abbrev](https://metacpan.org/pod/Text::Abbrev) - Testing utilities via [MooX::Cmd::Tester](https://metacpan.org/pod/MooX::Cmd::Tester) ## How It Works Commands are discovered via [Module::Pluggable](https://metacpan.org/pod/Module::Pluggable) under `YourApp::Cmd::*`. Subcommands nest further: `YourApp::Cmd::Foo::Cmd::Bar` handles `yourapp foo bar`. Each command in the chain is instantiated. Only the most specific (deepest) command's `execute` is called, but all parent instances are available through the command chain. ## With MooX::Options ```perl package MyApp; use Moo; use MooX::Cmd; use MooX::Options; option verbose => (is => 'ro', doc => 'Enable verbose output'); sub execute { my ($self, $args, $chain) = @_; say "Running in verbose mode" if $self->verbose; } ``` ``` $ myapp --verbose Running in verbose mode ``` ## Installation ``` cpanm MooX::Cmd ``` ## Documentation Full documentation is available on [MetaCPAN](https://metacpan.org/pod/MooX::Cmd). ## License This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. META.json100644001750001750 4500415150637252 14303 0ustar00gettygetty000000000000MooX-Cmd-1.000{ "abstract" : "Giving an easy Moo style way to make command organized CLI apps", "author" : [ "Torsten Raudssus " ], "dynamic_config" : 0, "generated_by" : "Dist::Zilla version 6.032, CPAN::Meta::Converter version 2.150010", "license" : [ "perl_5" ], "meta-spec" : { "url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec", "version" : 2 }, "name" : "MooX-Cmd", "prereqs" : { "configure" : { "requires" : { "ExtUtils::MakeMaker" : "0" } }, "develop" : { "recommends" : { "Dist::Zilla::PluginBundle::Git::VersionManager" : "0.007" }, "requires" : { "Test::CPAN::Changes" : "0", "Test::Kwalitee" : "0", "Test::Perl::Critic" : "0", "Test::PerlTidy" : "0", "Test::Pod" : "1.41", "Test::Pod::Coverage" : "0", "Test::Pod::Spelling::CommonMistakes" : "0", "Test::Spelling" : "0" } }, "runtime" : { "recommends" : { "Hash::Merge" : "0.299", "MooX::ConfigFromFile" : "0.008", "Text::Abbrev" : "0" }, "requires" : { "Carp" : "0", "List::MoreUtils" : "0.406", "Module::Pluggable" : "4.8", "Module::Runtime" : "0", "Moo" : "0.009013", "Package::Stash" : "0.33", "Params::Util" : "0.37", "Regexp::Common" : "2011121001", "Scalar::Util" : "0", "Text::ParseWords" : "0" } }, "test" : { "requires" : { "Capture::Tiny" : "0", "Test::More" : "0.98" } } }, "release_status" : "stable", "resources" : { "bugtracker" : { "web" : "https://github.com/Getty/p5-moox-cmd/issues" }, "homepage" : "https://github.com/Getty/p5-moox-cmd", "repository" : { "type" : "git", "url" : "https://github.com/Getty/p5-moox-cmd.git", "web" : "https://github.com/Getty/p5-moox-cmd" }, "x_IRC" : "irc://irc.perl.org/#web-simple", "x_IRC_user" : "Getty" }, "version" : "1.000", "x_Dist_Zilla" : { "perl" : { "version" : "5.036000" }, "plugins" : [ { "class" : "Dist::Zilla::Plugin::Git::GatherDir", "config" : { "Dist::Zilla::Plugin::GatherDir" : { "exclude_filename" : [], "exclude_match" : [], "include_dotfiles" : 1, "prefix" : "", "prune_directory" : [], "root" : "." }, "Dist::Zilla::Plugin::Git::GatherDir" : { "include_untracked" : 0 } }, "name" : "@Author::GETTY/Git::GatherDir", "version" : "2.052" }, { "class" : "Dist::Zilla::Plugin::ManifestSkip", "name" : "@Author::GETTY/@Filter/ManifestSkip", "version" : "6.032" }, { "class" : "Dist::Zilla::Plugin::MetaYAML", "name" : "@Author::GETTY/@Filter/MetaYAML", "version" : "6.032" }, { "class" : "Dist::Zilla::Plugin::License", "name" : "@Author::GETTY/@Filter/License", "version" : "6.032" }, { "class" : "Dist::Zilla::Plugin::Readme", "name" : "@Author::GETTY/@Filter/Readme", "version" : "6.032" }, { "class" : "Dist::Zilla::Plugin::ExtraTests", "name" : "@Author::GETTY/@Filter/ExtraTests", "version" : "6.032" }, { "class" : "Dist::Zilla::Plugin::ExecDir", "name" : "@Author::GETTY/@Filter/ExecDir", "version" : "6.032" }, { "class" : "Dist::Zilla::Plugin::ShareDir", "name" : "@Author::GETTY/@Filter/ShareDir", "version" : "6.032" }, { "class" : "Dist::Zilla::Plugin::MakeMaker", "config" : { "Dist::Zilla::Role::TestRunner" : { "default_jobs" : 1 } }, "name" : "@Author::GETTY/@Filter/MakeMaker", "version" : "6.032" }, { "class" : "Dist::Zilla::Plugin::Manifest", "name" : "@Author::GETTY/@Filter/Manifest", "version" : "6.032" }, { "class" : "Dist::Zilla::Plugin::TestRelease", "name" : "@Author::GETTY/@Filter/TestRelease", "version" : "6.032" }, { "class" : "Dist::Zilla::Plugin::ConfirmRelease", "name" : "@Author::GETTY/@Filter/ConfirmRelease", "version" : "6.032" }, { "class" : "Dist::Zilla::Plugin::UploadToCPAN", "name" : "@Author::GETTY/@Filter/UploadToCPAN", "version" : "6.032" }, { "class" : "Dist::Zilla::Plugin::MetaConfig", "name" : "@Author::GETTY/MetaConfig", "version" : "6.032" }, { "class" : "Dist::Zilla::Plugin::MetaJSON", "name" : "@Author::GETTY/MetaJSON", "version" : "6.032" }, { "class" : "Dist::Zilla::Plugin::PodSyntaxTests", "name" : "@Author::GETTY/PodSyntaxTests", "version" : "6.032" }, { "class" : "Dist::Zilla::Plugin::GithubMeta", "name" : "@Author::GETTY/GithubMeta", "version" : "0.58" }, { "class" : "Dist::Zilla::Plugin::MetaResources", "name" : "@Author::GETTY/MetaResources", "version" : "6.032" }, { "class" : "Dist::Zilla::Plugin::InstallRelease", "name" : "@Author::GETTY/InstallRelease", "version" : "0.008" }, { "class" : "Dist::Zilla::Plugin::Authority", "name" : "@Author::GETTY/Authority", "version" : "1.009" }, { "class" : "Dist::Zilla::Plugin::Git::CheckFor::CorrectBranch", "config" : { "Dist::Zilla::Role::Git::Repo" : { "git_version" : "2.39.5", "repo_root" : "." } }, "name" : "@Author::GETTY/Git::CheckFor::CorrectBranch", "version" : "0.014" }, { "class" : "Dist::Zilla::Plugin::Prereqs::FromCPANfile", "name" : "@Author::GETTY/Prereqs::FromCPANfile", "version" : "0.08" }, { "class" : "Dist::Zilla::Plugin::PodWeaver", "config" : { "Dist::Zilla::Plugin::PodWeaver" : { "config_plugins" : [ "@Author::GETTY" ], "finder" : [ ":InstallModules", ":PerlExecFiles" ], "plugins" : [ { "class" : "Pod::Weaver::Plugin::EnsurePod5", "name" : "@CorePrep/EnsurePod5", "version" : "4.020" }, { "class" : "Pod::Weaver::Plugin::H1Nester", "name" : "@CorePrep/H1Nester", "version" : "4.020" }, { "class" : "Pod::Weaver::Plugin::SingleEncoding", "name" : "@GETTY/SingleEncoding", "version" : "4.020" }, { "class" : "Pod::Weaver::Section::Name", "name" : "@GETTY/Name", "version" : "4.020" }, { "class" : "Pod::Weaver::Section::Version", "name" : "@GETTY/Version", "version" : "4.020" }, { "class" : "Pod::Weaver::Section::Region", "name" : "@GETTY/Prelude", "version" : "4.020" }, { "class" : "Pod::Weaver::Section::Generic", "name" : "@GETTY/Synopsis", "version" : "4.020" }, { "class" : "Pod::Weaver::Section::Generic", "name" : "@GETTY/Description", "version" : "4.020" }, { "class" : "Pod::Weaver::Section::Generic", "name" : "@GETTY/Overview", "version" : "4.020" }, { "class" : "Pod::Weaver::Section::Generic", "name" : "@GETTY/Stability", "version" : "4.020" }, { "class" : "Pod::Weaver::Section::Leftovers", "name" : "@GETTY/Leftovers", "version" : "4.020" }, { "class" : "Pod::Weaver::Section::Region", "name" : "@GETTY/postlude", "version" : "4.020" }, { "class" : "Pod::Weaver::Section::GenerateSection", "name" : "@GETTY/Support", "version" : "4.020" }, { "class" : "Pod::Weaver::Section::GenerateSection", "name" : "@GETTY/Contributing", "version" : "4.020" }, { "class" : "Pod::Weaver::Section::Authors", "name" : "@GETTY/Authors", "version" : "4.020" }, { "class" : "Pod::Weaver::Section::Legal", "name" : "@GETTY/Legal", "version" : "4.020" }, { "class" : "Pod::Weaver::Plugin::Transformer", "name" : "@GETTY/List", "version" : "4.020" }, { "class" : "Pod::Weaver::Plugin::Transformer", "name" : "@GETTY/GETTY", "version" : "4.020" } ] } }, "name" : "@Author::GETTY/PodWeaver", "version" : "4.010" }, { "class" : "Dist::Zilla::Plugin::Prereqs", "config" : { "Dist::Zilla::Plugin::Prereqs" : { "phase" : "develop", "type" : "recommends" } }, "name" : "@Author::GETTY/@Git::VersionManager/pluginbundle version", "version" : "6.032" }, { "class" : "Dist::Zilla::Plugin::RewriteVersion::Transitional", "config" : { "Dist::Zilla::Plugin::RewriteVersion" : { "add_tarball_name" : 0, "finders" : [ ":ExecFiles", ":InstallModules" ], "global" : 0, "skip_version_provider" : 0 }, "Dist::Zilla::Plugin::RewriteVersion::Transitional" : {} }, "name" : "@Author::GETTY/@Git::VersionManager/RewriteVersion::Transitional", "version" : "0.009" }, { "class" : "Dist::Zilla::Plugin::MetaProvides::Update", "name" : "@Author::GETTY/@Git::VersionManager/MetaProvides::Update", "version" : "0.007" }, { "class" : "Dist::Zilla::Plugin::CopyFilesFromRelease", "config" : { "Dist::Zilla::Plugin::CopyFilesFromRelease" : { "filename" : [ "Changes" ], "match" : [] } }, "name" : "@Author::GETTY/@Git::VersionManager/CopyFilesFromRelease", "version" : "0.007" }, { "class" : "Dist::Zilla::Plugin::Git::Commit", "config" : { "Dist::Zilla::Plugin::Git::Commit" : { "add_files_in" : [], "commit_msg" : "v%V%n%n%c", "signoff" : 0 }, "Dist::Zilla::Role::Git::DirtyFiles" : { "allow_dirty" : [ "Changes" ], "allow_dirty_match" : [], "changelog" : "Changes" }, "Dist::Zilla::Role::Git::Repo" : { "git_version" : "2.39.5", "repo_root" : "." }, "Dist::Zilla::Role::Git::StringFormatter" : { "time_zone" : "local" } }, "name" : "@Author::GETTY/@Git::VersionManager/release snapshot", "version" : "2.052" }, { "class" : "Dist::Zilla::Plugin::Git::Tag", "config" : { "Dist::Zilla::Plugin::Git::Tag" : { "branch" : null, "changelog" : "Changes", "signed" : 0, "tag" : "1.000", "tag_format" : "%v", "tag_message" : "v%V" }, "Dist::Zilla::Role::Git::Repo" : { "git_version" : "2.39.5", "repo_root" : "." }, "Dist::Zilla::Role::Git::StringFormatter" : { "time_zone" : "local" } }, "name" : "@Author::GETTY/@Git::VersionManager/Git::Tag", "version" : "2.052" }, { "class" : "Dist::Zilla::Plugin::BumpVersionAfterRelease::Transitional", "config" : { "Dist::Zilla::Plugin::BumpVersionAfterRelease" : { "finders" : [ ":ExecFiles", ":InstallModules" ], "global" : 0, "munge_makefile_pl" : 1 }, "Dist::Zilla::Plugin::BumpVersionAfterRelease::Transitional" : {} }, "name" : "@Author::GETTY/@Git::VersionManager/BumpVersionAfterRelease::Transitional", "version" : "0.009" }, { "class" : "Dist::Zilla::Plugin::NextRelease", "name" : "@Author::GETTY/@Git::VersionManager/NextRelease", "version" : "6.032" }, { "class" : "Dist::Zilla::Plugin::Git::Commit", "config" : { "Dist::Zilla::Plugin::Git::Commit" : { "add_files_in" : [], "commit_msg" : "increment $VERSION after %v release", "signoff" : 0 }, "Dist::Zilla::Role::Git::DirtyFiles" : { "allow_dirty" : [ "Build.PL", "Changes", "Makefile.PL" ], "allow_dirty_match" : [ "(?^:^lib/.*\\.pm$)" ], "changelog" : "Changes" }, "Dist::Zilla::Role::Git::Repo" : { "git_version" : "2.39.5", "repo_root" : "." }, "Dist::Zilla::Role::Git::StringFormatter" : { "time_zone" : "local" } }, "name" : "@Author::GETTY/@Git::VersionManager/post-release commit", "version" : "2.052" }, { "class" : "Dist::Zilla::Plugin::Git::Push", "config" : { "Dist::Zilla::Plugin::Git::Push" : { "push_to" : [ "origin" ], "remotes_must_exist" : 1 }, "Dist::Zilla::Role::Git::Repo" : { "git_version" : "2.39.5", "repo_root" : "." } }, "name" : "@Author::GETTY/Git::Push", "version" : "2.052" }, { "class" : "Dist::Zilla::Plugin::FinderCode", "name" : ":InstallModules", "version" : "6.032" }, { "class" : "Dist::Zilla::Plugin::FinderCode", "name" : ":IncModules", "version" : "6.032" }, { "class" : "Dist::Zilla::Plugin::FinderCode", "name" : ":TestFiles", "version" : "6.032" }, { "class" : "Dist::Zilla::Plugin::FinderCode", "name" : ":ExtraTestFiles", "version" : "6.032" }, { "class" : "Dist::Zilla::Plugin::FinderCode", "name" : ":ExecFiles", "version" : "6.032" }, { "class" : "Dist::Zilla::Plugin::FinderCode", "name" : ":PerlExecFiles", "version" : "6.032" }, { "class" : "Dist::Zilla::Plugin::FinderCode", "name" : ":ShareFiles", "version" : "6.032" }, { "class" : "Dist::Zilla::Plugin::FinderCode", "name" : ":MainModule", "version" : "6.032" }, { "class" : "Dist::Zilla::Plugin::FinderCode", "name" : ":AllFiles", "version" : "6.032" }, { "class" : "Dist::Zilla::Plugin::FinderCode", "name" : ":NoFiles", "version" : "6.032" } ], "zilla" : { "class" : "Dist::Zilla::Dist::Builder", "config" : { "is_trial" : 0 }, "version" : "6.032" } }, "x_authority" : "cpan:GETTY", "x_generated_by_perl" : "v5.36.0", "x_serialization_backend" : "Cpanel::JSON::XS version 4.38", "x_spdx_expression" : "Artistic-1.0-Perl OR GPL-1.0-or-later" } .gitignore100644001750001750 3515150637252 14565 0ustar00gettygetty000000000000MooX-Cmd-1.000MooX-Cmd-* .build/ cover_db/ .perltidyrc100644001750001750 17415150637252 15003 0ustar00gettygetty000000000000MooX-Cmd-1.000-b -bl -noll -pt=2 -bt=2 -sbt=2 -vt=0 -vtc=0 -dws -aws -nsfs -asc -bbt=0 -cab=0 -l=130 -ole=unix --noblanks-before-comments t000755001750001750 015150637252 12742 5ustar00gettygetty000000000000MooX-Cmd-1.00000-load.t100644001750001750 55615150637252 14411 0ustar00gettygetty000000000000MooX-Cmd-1.000/t#!/usr/bin/perl use strict; use warnings; use Test::More; my $moodel; BEGIN { $moodel = $ENV{WHICH_MOODEL} || "Moo"; eval "use $moodel;"; $@ and die $@; $moodel->import; use_ok('MooX::Cmd') || BAIL_OUT("Couldn't load MooX::Cmd"); } diag("Testing MooX::Cmd $MooX::Cmd::VERSION, $moodel " . $moodel->VERSION . ", Perl $], $^X"); done_testing; xt000755001750001750 015150637252 13132 5ustar00gettygetty000000000000MooX-Cmd-1.000pod-cm.t100644001750001750 44315150637252 14617 0ustar00gettygetty000000000000MooX-Cmd-1.000/xt#!perl use strict; use warnings; use Test::More; BEGIN { eval { require Test::Pod::Spelling::CommonMistakes } or plan skip_all => "Test::Pod::Spelling::CommonMistakes required for this test"; } use Test::Pod::Spelling::CommonMistakes qw(all_pod_files_ok); all_pod_files_ok(); Makefile.PL100644001750001750 310015150637252 14603 0ustar00gettygetty000000000000MooX-Cmd-1.000# This file was automatically generated by Dist::Zilla::Plugin::MakeMaker v6.032. use strict; use warnings; use ExtUtils::MakeMaker; my %WriteMakefileArgs = ( "ABSTRACT" => "Giving an easy Moo style way to make command organized CLI apps", "AUTHOR" => "Torsten Raudssus ", "CONFIGURE_REQUIRES" => { "ExtUtils::MakeMaker" => 0 }, "DISTNAME" => "MooX-Cmd", "LICENSE" => "perl", "NAME" => "MooX::Cmd", "PREREQ_PM" => { "Carp" => 0, "List::MoreUtils" => "0.406", "Module::Pluggable" => "4.8", "Module::Runtime" => 0, "Moo" => "0.009013", "Package::Stash" => "0.33", "Params::Util" => "0.37", "Regexp::Common" => "2011121001", "Scalar::Util" => 0, "Text::ParseWords" => 0 }, "TEST_REQUIRES" => { "Capture::Tiny" => 0, "Test::More" => "0.98" }, "VERSION" => "1.000", "test" => { "TESTS" => "t/*.t" } ); my %FallbackPrereqs = ( "Capture::Tiny" => 0, "Carp" => 0, "List::MoreUtils" => "0.406", "Module::Pluggable" => "4.8", "Module::Runtime" => 0, "Moo" => "0.009013", "Package::Stash" => "0.33", "Params::Util" => "0.37", "Regexp::Common" => "2011121001", "Scalar::Util" => 0, "Test::More" => "0.98", "Text::ParseWords" => 0 ); unless ( eval { ExtUtils::MakeMaker->VERSION(6.63_03) } ) { delete $WriteMakefileArgs{TEST_REQUIRES}; delete $WriteMakefileArgs{BUILD_REQUIRES}; $WriteMakefileArgs{PREREQ_PM} = \%FallbackPrereqs; } delete $WriteMakefileArgs{CONFIGURE_REQUIRES} unless eval { ExtUtils::MakeMaker->VERSION(6.52) }; WriteMakefile(%WriteMakefileArgs); changes.t100644001750001750 50415150637252 15046 0ustar00gettygetty000000000000MooX-Cmd-1.000/xt#!perl use strict; use warnings; use Test::More; use Test::CPAN::Changes; # Skip when running from source tree ({{$NEXT}} placeholder present) my $changes = do { local $/; open my $fh, '<', 'Changes' or die $!; <$fh> }; plan skip_all => 'Changes contains dzil placeholder' if $changes =~ /\{\{\$NEXT\}\}/; changes_ok(); 01-simple.t100644001750001750 440115150637252 14775 0ustar00gettygetty000000000000MooX-Cmd-1.000/t#!/usr/bin/perl use strict; use warnings; use Test::More; use MooX::Cmd::Tester; use FindBin qw($Bin); use lib "$Bin/lib"; use FirstTestApp; use SecondTestApp; use ThirdTestApp; use FailTestApp; my @tests = ( ['test', ["FirstTestApp::Cmd::Test", [], ["FirstTestApp"]]], ['test test', ["FirstTestApp::Cmd::Test::Cmd::Test", [], ["FirstTestApp", "FirstTestApp::Cmd::Test"]]], ['test this', ["FirstTestApp::Cmd::Test", ["this"], ["FirstTestApp"]]], ['this test test this', ["FirstTestApp::Cmd::Test::Cmd::Test", ["this"], ["FirstTestApp", "FirstTestApp::Cmd::Test"]]], ['test this test', ["FirstTestApp::Cmd::Test::Cmd::Test", [], ["FirstTestApp", "FirstTestApp::Cmd::Test"]]], ['ifc', ["SecondTestApp::Cmd::ifc", [], ["SecondTestApp"]]], ['cwo', ["SecondTestApp::Cmd::cwo", [], ["SecondTestApp"]]], ); for (@tests) { my ($args, $result) = @{$_}; ref $args or $args = [split(' ', $args)]; my $rv = test_cmd_ok($result->[2]->[0] => $args); # my $app = FirstTestApp->new_with_cmd; # isa_ok($app,'FirstTestApp'); #my @execute_return = @{$app->execute_return}; "ARRAY" eq ref $rv->execute_rv or diag(explain($rv)); my @execute_return = @{$rv->execute_rv}; my @moox_cmd_chain = map { ref $_ } @{$execute_return[2]}; push @{$result->[2]}, $result->[0]; my $execute_result = [ref $execute_return[0], $execute_return[1], \@moox_cmd_chain]; is_deeply($execute_result, $result, 'Checking result of "' . join(" ", @$args) . '"'); } { my $rv = test_cmd_ok(ThirdTestApp => [qw(foo)]); my $nothing; is_deeply(\$nothing, \$rv->{execute_return}, 'Checking result of "ThirdTestApp => [foo]"'); } { my $rv = test_cmd(FailTestApp => [qw(nothing)]); like($rv->error, qr/need.*execute.*nothing/, "Load fails for FailTestApp => [nothing]"); } { my $rv = test_cmd(FailTestApp => [qw(uncreatable)]); like($rv->error, qr/Can't find a creation method/, "Load fails for FailTestApp => [nothing]"); } { my $rv = test_cmd(FailTestApp => [qw(nocreatable)]); like($rv->error, qr/Can't find a creation method/, "Load fails for FailTestApp => [nothing]"); } done_testing; 03-params.t100644001750001750 714315150637252 14777 0ustar00gettygetty000000000000MooX-Cmd-1.000/t#!/usr/bin/perl use strict; use warnings; use Test::More; use MooX::Cmd::Tester; use FindBin qw($Bin); use lib "$Bin/lib"; use FirstTestApp; use SecondTestApp; use ThirdTestApp; { local @ARGV; my $cmd = SecondTestApp->new_with_cmd(command_execute_method_name => "run"); my $rv = test_cmd_ok($cmd, []); my @execute_return = @{$rv->execute_rv}; is_deeply(\@execute_return, [$cmd], 'Checking result of "SecondTestApp(command_base => "SecondTestApp::Cmd") => []"'); } { local @ARGV; my $cmd = SecondTestApp->new_with_cmd(command_base => "SecondTestApp::Cmd"); my $rv = test_cmd_ok($cmd, []); my @execute_return = @{$rv->execute_rv}; is_deeply(\@execute_return, [$cmd], 'Checking result of "SecondTestApp(command_base => "SecondTestApp::Cmd") => []"'); } { local @ARGV; my $cmd = SecondTestApp->new_with_cmd(command_creation_chain_methods => "new"); my $rv = test_cmd_ok($cmd, []); my @execute_return = @{$rv->execute_rv}; is_deeply(\@execute_return, [$cmd], 'Checking result of "SecondTestApp(command_creation_chain_methods => "new") => []"'); } { local @ARGV; my $cmd = SecondTestApp->new_with_cmd( command_commands => { ifc => "SecondTestApp::Cmd::ifc", cwo => "SecondTestApp::Cmd::cwo" } ); my $rv = test_cmd_ok($cmd, []); my @execute_return = @{$rv->execute_rv}; is_deeply(\@execute_return, [$cmd], 'Checking result of "SecondTestApp(command_commands => {ifc => "SecondTestApp::Cmd::ifc", cwo => "SecondTestApp::Cmd::cwo"}) => []"' ); } { local @ARGV; my $cmd = SecondTestApp->new_with_cmd( command_base => "SecondTestApp::Cmd", command_creation_chain_methods => "new" ); my $rv = test_cmd_ok($cmd, []); my @execute_return = @{$rv->execute_rv}; is_deeply(\@execute_return, [$cmd], 'Checking result of "SecondTestApp(command_base => "SecondTestApp::Cmd") => []"'); } { local @ARGV = qw(foo); my $cmd = ThirdTestApp->new_with_cmd(command_execute_from_new => undef); my $rv = test_cmd_ok($cmd, [qw(foo)]); is($rv->execute_rv, undef, 'Checking result of "ThirdTestApp(command_execute_from_new => undef) => []"'); } { local @ARGV = qw(foo); my $cmd = ThirdTestApp->new_with_cmd(command_execute_from_new => 0); my $rv = test_cmd_ok($cmd, [qw(foo)]); is_deeply($rv->execute_rv, undef, 'Checking result of "ThirdTestApp(command_execute_from_new => 0) => []"'); } { local @ARGV; my $cmd = SecondTestApp->new_with_cmd(command_execute_return_method_name => "was_haste"); my $rv = test_cmd_ok($cmd, []); my @execute_return = @{$rv->execute_rv}; is_deeply(\@execute_return, [$cmd], 'Checking result of "SecondTestApp(command_execute_return_method_name => "was_haste") => []"'); } { local @ARGV; eval { my $cmd = SecondTestApp->new_with_cmd(command_creation_chain_methods => "search_me"); }; like( $@, qr/Can't find a creation method on/, 'Load fails for SecondTestApp(command_creation_chain_methods => "search_me") => []' ); } SKIP: { eval "use MooX::Options 4.100; use OptionTestApp"; $@ and skip("MooX::Options required 4.100 $@", 1); local @ARGV = qw(oops); my $cmd = eval { OptionTestApp->new_with_cmd(command_creation_chain_methods => "new_with_options"); }; like( $@, qr/Can't find a creation method on/, 'Load fails for OptionTestApp(command_creation_chain_methods => "new_with_options") => []' ); } done_testing; kwalitee.t100644001750001750 65115150637252 15246 0ustar00gettygetty000000000000MooX-Cmd-1.000/xt#!perl use strict; use warnings; use Test::More; # kwalitee checks require a built distribution (Makefile.PL, MANIFEST, META.yml) plan skip_all => "kwalitee test only works on a built distribution" unless -f 'Makefile.PL' || -f 'Build.PL'; BEGIN { eval { require Test::Kwalitee } or plan skip_all => "Test::Kwalitee required for this test"; } use Test::Kwalitee 'kwalitee_ok'; kwalitee_ok(); done_testing; perltidy.t100644001750001750 34315150637252 15273 0ustar00gettygetty000000000000MooX-Cmd-1.000/xt#!perl use strict; use warnings; use Test::More; BEGIN { eval { require Test::PerlTidy } or plan skip_all => "Test::PerlTidy required for this test"; } use Test::PerlTidy; run_tests(perltidyrc => '.perltidyrc'); spelling.t100644001750001750 70715150637252 15260 0ustar00gettygetty000000000000MooX-Cmd-1.000/xt#!perl use strict; use warnings; use Test::More; BEGIN { eval { require Test::Spelling } or plan skip_all => "Test::Spelling required for this test"; } use Test::Spelling; add_stopwords(); all_pod_files_spelling_ok(); __END__ AnnoCPAN ArrayRef BOOL BUILDARGS CLI CPAN Celogeek HashRef Inkster Jens Lukas Rehsack Raudssus Ricardo Signes Subcommand Toplevel argv cli cmd eXtension mauke rehsack subcommand subcommands tobyink toplevel MooX000755001750001750 015150637252 14127 5ustar00gettygetty000000000000MooX-Cmd-1.000/libCmd.pm100644001750001750 2454215150637252 15357 0ustar00gettygetty000000000000MooX-Cmd-1.000/lib/MooXpackage MooX::Cmd; # ABSTRACT: Giving an easy Moo style way to make command organized CLI apps our $VERSION = '1.000'; use strict; use warnings; use Package::Stash; sub import { my (undef, %import_options) = @_; my $caller = caller; my @caller_isa; ## no critic qw(ProhibitNoStrict) { no strict 'refs'; @caller_isa = @{"${caller}::ISA"} }; #don't add this to a role #ISA of a role is always empty ! @caller_isa or return; my $execute_return_method_name = $import_options{execute_return_method_name}; exists $import_options{execute_from_new} or $import_options{execute_from_new} = 1; # set default until we want other way my $stash = Package::Stash->new($caller); defined $import_options{execute_return_method_name} and $stash->add_symbol('&' . $import_options{execute_return_method_name}, sub { shift->{$import_options{execute_return_method_name}} }); defined $import_options{creation_method_name} or $import_options{creation_method_name} = "new_with_cmd"; $stash->add_symbol('&' . $import_options{creation_method_name}, sub { shift->_initialize_from_cmd(@_); }); my $apply_modifiers = sub { $caller->can('_initialize_from_cmd') and return; my $with = $caller->can('with'); $with->('MooX::Cmd::Role'); # XXX prove whether it can chained ... $import_options{with_config_from_file} and $with->('MooX::ConfigFromFile::Role'); $import_options{with_config_from_file} and $with->('MooX::Cmd::Role::ConfigFromFile'); $import_options{with_abbrev_cmds} and $with->('MooX::Cmd::Role::AbbrevCmds'); }; $apply_modifiers->(); my %default_modifiers = ( base => '_build_command_base', execute_method_name => '_build_command_execute_method_name', execute_return_method_name => '_build_command_execute_return_method_name', creation_chain_methods => '_build_command_creation_chain_methods', creation_method_name => '_build_command_creation_method_name', execute_from_new => '_build_command_execute_from_new', ); my $around; foreach my $opt_key (keys %default_modifiers) { exists $import_options{$opt_key} or next; $around or $around = $caller->can('around'); $around->($default_modifiers{$opt_key} => sub { $import_options{$opt_key} }); } return; } 1; __END__ =pod =encoding UTF-8 =head1 NAME MooX::Cmd - Giving an easy Moo style way to make command organized CLI apps =head1 VERSION version 1.000 =head1 SYNOPSIS package MyApp; use Moo; use MooX::Cmd; sub execute { my ( $self, $args_ref, $chain_ref ) = @_; my @extra_argv = @{$args_ref}; my @chain = @{$chain_ref} # in this case only ( $myapp ) # where $myapp == $self } 1; package MyApp::Cmd::Command; # for "myapp command" use Moo; use MooX::Cmd; # gets executed on "myapp command" but not on "myapp command command" # there MyApp::Cmd::Command still gets instantiated and for the chain sub execute { my ( $self, $args_ref, $chain_ref ) = @_; my @chain = @{$chain_ref} # in this case ( $myapp, $myapp_cmd_command ) # where $myapp_cmd_command == $self } 1; package MyApp::Cmd::Command::Cmd::Command; # for "myapp command command" use Moo; use MooX::Cmd; # gets executed on "myapp command command" and will not get instantiated # on "myapp command" cause it doesnt appear in the chain there sub execute { my ( $self, $args_ref, $chain_ref ) = @_; my @chain = @{$chain_ref} # in this case ( $myapp, $myapp_cmd_command, # $myapp_cmd_command_cmd_command ) # where $myapp_cmd_command_cmd_command == $self } package MyZapp; use Moo; use MooX::Cmd execute_from_new => 0; sub execute { my ( $self ) = @_; my @extra_argv = @{$self->command_args}; my @chain = @{$self->command_chain} # in this case only ( $myzapp ) # where $myzapp == $self } 1; package MyZapp::Cmd::Command; # for "myapp command" use Moo; use MooX::Cmd execute_from_new => 0; # gets executed on "myapp command" but not on "myapp command command" # there MyApp::Cmd::Command still gets instantiated and for the chain sub execute { my ( $self ) = @_; my @extra_argv = @{$self->command_args}; my @chain = @{$self->command_chain} # in this case ( $myzapp, $myzapp_cmd_command ) # where $myzapp_cmd_command == $self } 1; package main; use MyApp; MyZapp->new_with_cmd->execute(); MyApp->new_with_cmd; 1; =head1 DESCRIPTION Eases the writing of command line utilities, accepting commands and subcommands and so on. These commands can form a tree, which is mirrored in the package structure. On invocation each command along the path through the tree (starting from the toplevel command through to the most specific one) is instantiated. Each command needs to have an C function, accepting three parameters: =over =item C A reference to the specific L object that is executing. =item C An ArrayRef of arguments passed to C. This only encompasses arguments of the most specific (read: right-most) command. =item C An ArrayRef of Cs along the tree path, as specified on the command line. =back B =head3 L Attributes Each command has some attributes set by L during initialization: =over =item C Same as C argument to C. =item C The name of the command as found on the command line. =item C HashRef of available subcommands for this command. =item C ArrayRef of remaining arguments after command parsing. =item C The base namespace for searching subcommand plugins. =back =head2 Examples =head3 A Single Toplevel Command #!/usr/bin/env perl package MyApp; use Moo; use MooX::Cmd; sub execute { my ($self,$args,$chain) = @_; printf("%s.execute(\$self,[%s],[%s])\n", ref($self), # which command is executing? join(", ", @$args ), # what where the arguments? join(", ", map { ref } @$chain) # what's in the command chain? ); } package main; MyApp->new_with_cmd(); Some sample invocations: $ ./MyApp.pl MyApp.execute($self,[],[MyApp]) $./MyApp.pl --opt1 MyApp.execute($self,[--opt1],[MyApp]) $ ./MyApp.pl --opt1 arg MyApp.execute($self,[--opt1, arg],[MyApp]) =head3 Toplevel Command with Subcommand #!/usr/bin/env perl # let's define a base class containing our generic execute # function to save some typing... package CmdBase; use Moo; sub execute { my ($self,$args,$chain) = @_; printf("%s.execute(\$self,[%s],[%s])\n", ref($self), join(", ", @$args ), join(", ", map { ref } @$chain) ); } package MyApp; # toplevel command/app use Moo; use MooX::Cmd; extends 'CmdBase'; package MyApp::Cmd::frobnicate; # can be called via ./MyApp.pl frobnicate use Moo; use MooX::Cmd; extends 'CmdBase'; package main; MyApp->new_with_cmd(); And some sample invocations: $ ./MyApp.pl frobnicate MyApp::Cmd::frobnicate.execute($self,[],[MyApp, MyApp::Cmd::frobnicate]) As you can see the chain contains our toplevel command object and then the specific one. $ ./MyApp.pl frobnicate arg1 MyApp::Cmd::frobnicate.execute($self,[arg1],[MyApp, MyApp::Cmd::frobnicate]) Arguments are passed via the C parameter. $ ./MyApp.pl some --stuff frobnicate arg1 MyApp::Cmd::frobnicate.execute($self,[arg1],[MyApp, MyApp::Cmd::frobnicate]) Arguments to commands higher in the tree get ignored if they don't match a command. =head3 Access Toplevel Attributes via Chain #!/usr/bin/env perl package CmdBase; use Moo; sub execute { my ($self,$args,$chain) = @_; printf("%s.execute(\$self,[%s],[%s])\n", ref($self), join(", ", @$args ), join(", ", map { ref } @$chain) ); } package MyApp; use Moo; use MooX::Cmd; extends 'CmdBase'; has somevar => ( is => 'ro', default => 'someval' ); package MyApp::Cmd::frobnicate; use Moo; use MooX::Cmd; extends 'CmdBase'; around execute => sub { my ($orig,$self,$args,$chain) = @_; $self->$orig($args,$chain); # we can access toplevel attributes via the chain... printf("MyApp->somevar = '%s'\n", $chain->[0]->somevar); }; package main; MyApp->new_with_cmd(); A sample invocation $ ./MyApp.pl some --stuff frobnicate arg1 MyApp::Cmd::frobnicate.execute($self,[arg1],[MyApp, MyApp::Cmd::frobnicate]) MyApp->somevar = someval =head2 L integration You can integrate L simply by using it and declaring some options, like so: #!/usr/bin/env perl package MyApp; use Moo; use MooX::Cmd; use MooX::Options; option debug => ( is => 'ro' ); sub execute { my ($self,$args,$chain) = @_; print "debugging enabled!\n" if $self->{debug}; } package main; MyApp->new_with_cmd(); A sample invocation $ ./MyApp-Options.pl --debug debugging enabled! B, so options are parsed for the specific context and used for the instantiation: $ ./MyApp.pl --argformyapp command --argformyappcmdcommand ... =head1 THANKS =over =item Jens Rehsack (rehsack) Co-maintained MooX::Cmd from 2013 to 2017, major contributions to MooX::Cmd::Role, MooX::Cmd::Tester and the test suite =item Lukas Mai (mauke), Toby Inkster (tobyink) Gave some helpful advice for solving difficult issues =item Celogeek San Integration into MooX::Options for better help messages and suit team play =back =head1 SUPPORT =head2 Issues Please report bugs and feature requests on GitHub at L. =head2 IRC Join C<#web-simple> on C or message Getty directly. =head1 CONTRIBUTING Contributions are welcome! Please fork the repository and submit a pull request. =head1 AUTHOR Torsten Raudssus =head1 COPYRIGHT AND LICENSE This software is copyright (c) 2026 by Torsten Raudssus. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. =cut perlcritic.t100644001750001750 23115150637252 15573 0ustar00gettygetty000000000000MooX-Cmd-1.000/xt#!perl use strict; use warnings; use Test::More; use Test::Perl::Critic; Test::Perl::Critic->import(-profile => 'xt/perlcritic.rc'); all_critic_ok(); perlcritic.rc100644001750001750 74215150637252 15743 0ustar00gettygetty000000000000MooX-Cmd-1.000/xtseverity = 3 verbose = 6 top = 50 theme = pbp || core || bugs || security || maintenance criticism-fatal = 1 color = 1 [-Modules::ProhibitAutomaticExportation] [-Subroutines::RequireFinalReturn] [-Subroutines::RequireArgUnpacking] [-Subroutines::ProhibitUnusedPrivateSubroutines] [TestingAndDebugging::RequireUseStrict] equivalent_modules = strictures Moo [TestingAndDebugging::RequireUseWarnings] equivalent_modules = strictures Moo pod-coverage.t100644001750001750 163215150637252 16034 0ustar00gettygetty000000000000MooX-Cmd-1.000/xt#!perl use strict; use warnings; use Test::More; BEGIN { eval { require Test::Pod::Coverage } or plan skip_all => "Test::Pod::Coverage required for this test"; } use Test::Pod::Coverage; # MooX::Cmd has no real subs to document (just import) pod_coverage_ok('MooX::Cmd', {trustme => [qr/^import$/]}); # Role attributes are documented with =attr (rendered by PodWeaver at build time) # From source tree, Test::Pod::Coverage can't see the woven POD, # so we trust the attribute accessors and builder methods pod_coverage_ok( 'MooX::Cmd::Role', { trustme => [qr/^(command_|new_with_cmd|execute_return|_)/], } ); pod_coverage_ok( 'MooX::Cmd::Tester', { trustme => [qr/^(test_cmd|test_cmd_ok|result_class)$/], } ); # Roles with no public API to document pod_coverage_ok('MooX::Cmd::Role::AbbrevCmds'); pod_coverage_ok('MooX::Cmd::Role::ConfigFromFile'); done_testing; 05-text-abbrev.t100644001750001750 353215150637252 15737 0ustar00gettygetty000000000000MooX-Cmd-1.000/t#!/usr/bin/perl use strict; use warnings; use Test::More; use Moo; use MooX::Cmd::Tester; use FindBin qw($Bin); use lib "$Bin/lib"; BEGIN { eval "use Text::Abbrev; use AbbrevApp"; $@ and plan skip_all => "Need Text::Abbrev -- $@" and exit(0); } diag("Testing MooX::Cmd version " . MooX::Cmd->VERSION . " using Text::Abbrev version " . Text::Abbrev->VERSION); my @tests = ( [[], "AbbrevApp", "AbbrevApp", {}], [ [qw(thuruksp)], "AbbrevApp", "AbbrevApp::Cmd::ThuruksPride", { race => "Split", security_level => "Core" } ], [ [qw(thuruksb)], "AbbrevApp", "AbbrevApp::Cmd::ThuruksBeard", { race => "Split", security_level => "Border" } ], ); SKIP: for (@tests) { my ($args, $class, $cmd_class, $attrs) = @{$_}; ref $args or $args = [split(' ', $args)]; my $rv = test_cmd($class => $args); #diag(explain($rv)); my $test_ident = "$class => " . join(" ", "[", @$args, "]"); ok($rv->cmd, "got cmd for $test_ident") or diag(explain($rv)); isa_ok($rv->cmd, $class) or skip("Cannot do attribute testing without command", 2); isa_ok($rv->cmd->command_chain_end, $cmd_class) or skip("Cannot do attribute testing without specific command", 1) if scalar @$args; my $cmd = scalar @$args ? $rv->cmd->command_chain_end : $rv->cmd; foreach my $k (keys %$attrs) { my $cmd_attr = $cmd->$k; ref $attrs->{$k} or is($attrs->{$k}, $cmd_attr, "Attribute $k for $test_ident"); "CODE" eq ref $attrs->{$k} and ok($attrs->{$k}->($cmd_attr), "Attribute $k ok for $test_ident"); ref $attrs->{$k} and "CODE" ne ref $attrs->{$k} and is_deeply($attrs->{$k}, $cmd_attr, "Attribute $k for $test_ident"); } } done_testing; lib000755001750001750 015150637252 13510 5ustar00gettygetty000000000000MooX-Cmd-1.000/tAbbrevApp.pm100644001750001750 34515150637252 16032 0ustar00gettygetty000000000000MooX-Cmd-1.000/t/libpackage AbbrevApp; use strict; use warnings; BEGIN { my $moodel = $ENV{WHICH_MOODEL} || "Moo"; eval "use $moodel;"; $@ and die $@; $moodel->import; } use MooX::Cmd with_abbrev_cmds => 1; sub execute { @_ } 1; ConfigApp.pm100644001750001750 46315150637252 16037 0ustar00gettygetty000000000000MooX-Cmd-1.000/t/libpackage ConfigApp; use strict; use warnings; BEGIN { my $moodel = $ENV{WHICH_MOODEL} || "Moo"; eval "use $moodel;"; $@ and die $@; $moodel->import; } use MooX::Cmd with_config_from_file => 1; has complicated_setting => ( is => "ro", required => 1 ); sub execute { @_ } 1; 02-moox-options.t100644001750001750 364215150637252 16166 0ustar00gettygetty000000000000MooX-Cmd-1.000/t#!/usr/bin/perl use strict; use warnings; use Test::More; use Moo; use MooX::Cmd::Tester; use FindBin qw($Bin); use lib "$Bin/lib"; BEGIN { eval "use MooX::Options 4.100; use OptionTestApp"; $@ and plan skip_all => "Need MooX::Options 4.100 $@" and exit(0); } diag("Testing MooX::Cmd version " . MooX::Cmd->VERSION . " using MooX::Options version " . MooX::Options->VERSION); my @tests = ( [[qw(--help)], "OptionTestApp", [], qr{\QUSAGE: 02-moox-options.t [-h]\E}, qr{\QSUB COMMANDS AVAILABLE: \E(?:oops|primary)}], [[qw(--in-doubt)], "OptionTestApp", [qw(OptionTestApp)]], [ [qw(primary --help)], "OptionTestApp", [], qr{\QUSAGE: 02-moox-options.t primary [-h]\E}, qr{\QSUB COMMANDS AVAILABLE: secondary\E} ], [[qw(primary --serious)], "OptionTestApp", [qw(OptionTestApp OptionTestApp::Cmd::primary)]], [[qw(--in-doubt primary secondary --help)], "OptionTestApp", [], qr{\QUSAGE: 02-moox-options.t primary secondary [-h]\E}], [ [qw(primary secondary --sure)], "OptionTestApp", [qw(OptionTestApp OptionTestApp::Cmd::primary OptionTestApp::Cmd::primary::Cmd::secondary)] ], ); for (@tests) { my ($args, $class, $chain, $help, $avail) = @{$_}; ref $args or $args = [split(' ', $args)]; my $rv = test_cmd($class => $args); my $test_ident = "$class => " . join(" ", "[", @$args, "]"); $help and like($rv->stdout, $help, "test '$test_ident' help message"); $help or unlike($rv->stdout, qr{\QUSAGE: 02-moox-options.t\E}, "test '$test_ident' no help message"); $avail and like($rv->stdout, $avail, "test '$test_ident' avail commands ok"); $avail or unlike($rv->stdout, qr{\QAvailable commands\E}, "test '$test_ident' no avail commands"); if (defined($rv->cmd)) { my @cmd_chain = map { ref $_ } @{$rv->cmd->command_chain}; is_deeply(\@cmd_chain, $chain, "test '$test_ident' command chain ok"); } } done_testing; Cmd000755001750001750 015150637252 14632 5ustar00gettygetty000000000000MooX-Cmd-1.000/lib/MooXRole.pm100644001750001750 2342515150637252 16257 0ustar00gettygetty000000000000MooX-Cmd-1.000/lib/MooX/Cmdpackage MooX::Cmd::Role; # ABSTRACT: MooX cli app commands do this our $VERSION = '1.000'; use strict; use warnings; use Moo::Role; use Carp; use Module::Runtime qw/ use_module /; use Regexp::Common; use Text::ParseWords 'shellwords'; use Module::Pluggable::Object; use List::MoreUtils qw/first_index first_result/; use Scalar::Util qw/blessed/; use Params::Util qw/_ARRAY/; has 'command_args' => (is => "ro"); has 'command_chain' => (is => "ro"); has 'command_chain_end' => (is => "lazy"); sub _build_command_chain_end { $_[0]->command_chain->[-1] } has 'command_name' => (is => "ro"); has 'command_commands' => (is => "lazy"); sub _build_command_commands { my ($class, $params) = @_; defined $params->{command_base} or $params->{command_base} = $class->_build_command_base($params); my $base = $params->{command_base}; # I have no clue why 'only' and 'except' seems to not fulfill what I need or are bugged in M::P - Getty my @cmd_plugins = grep { my $plug_class = _mkcommand($_, $base); index($plug_class, ":") == -1; } Module::Pluggable::Object->new( search_path => $base, require => 0, )->plugins; my %cmds = map { _mkcommand($_, $base) => $_ } @cmd_plugins; scalar keys %cmds == scalar @cmd_plugins or croak "Can't compute unambiguous list of commands from '" . join("', '", @cmd_plugins) . "'"; \%cmds; } has command_base => (is => "lazy"); sub _build_command_base { $_[0] . '::Cmd'; } has command_execute_method_name => (is => "lazy"); sub _build_command_execute_method_name { "execute" } has command_execute_return_method_name => (is => "lazy"); sub _build_command_execute_return_method_name { "execute_return" } has command_creation_method_name => (is => "lazy"); sub _build_command_creation_method_name { "new_with_cmd" } has command_creation_chain_methods => (is => "lazy"); sub _build_command_creation_chain_methods { ['new_with_options', 'new'] } has command_execute_from_new => (is => "lazy"); sub _build_command_execute_from_new { 0 } sub new_with_cmd { goto &_initialize_from_cmd; } sub _mkcommand { my ($package, $base) = @_; my $bwc = "${base}::"; my $len_bwc = length($bwc); index($package, $bwc) == 0 and substr($package, 0, $len_bwc, ""); lc($package); } my @private_init_params = qw(command_base command_execute_method_name command_execute_return_method_name command_creation_chain_methods command_execute_method_name); my $required_method = sub { my ($tgt, $method) = @_; $tgt->can($method) or croak("You need an '$method' in " . (blessed $tgt || $tgt)); }; my $call_required_method = sub { my ($tgt, $method, @args) = @_; my $m = $required_method->($tgt, $method); return $m->($tgt, @args); }; my $call_optional_method = sub { my ($tgt, $method, @args) = @_; my $m = $tgt->can($method) or return; return $m->($tgt, @args); }; my $call_indirect_method = sub { my ($tgt, $name_getter, @args) = @_; my $g = $call_required_method->($tgt, $name_getter); my $m = $required_method->($tgt, $g); return $m->($tgt, @args); }; ## no critic qw(ProhibitExcessComplexity) sub _initialize_from_cmd { my ($class, %params) = @_; my @args = shellwords(join ' ', map { quotemeta } @ARGV); my (@used_args, $cmd, $cmd_name, $cmd_name_index); my %cmd_create_params = %params; delete @cmd_create_params{qw(command_commands), @private_init_params}; defined $params{command_commands} or $params{command_commands} = $class->_build_command_commands(\%params); if (($cmd_name_index = first_index { $cmd = $params{command_commands}->{$_} } @args) >= 0) { @used_args = splice @args, 0, $cmd_name_index; shift @args; # be careful about relics $cmd_name = _mkcommand($cmd, $params{command_base}); use_module($cmd); defined $cmd_create_params{command_execute_method_name} or $cmd_create_params{command_execute_method_name} = $call_optional_method->($cmd, "_build_command_execute_method_name", \%cmd_create_params); defined $cmd_create_params{command_execute_method_name} or $cmd_create_params{command_execute_method_name} = "execute"; $required_method->($cmd, $cmd_create_params{command_execute_method_name}); } else { @used_args = @args; @args = (); } defined $params{command_creation_chain_methods} or $params{command_creation_chain_methods} = $class->_build_command_creation_chain_methods(\%params); my @creation_chain = _ARRAY($params{command_creation_chain_methods}) ? @{$params{command_creation_chain_methods}} : ($params{command_creation_chain_methods}); (my $creation_method = first_result { defined $_ and $class->can($_) } @creation_chain) or croak "Can't find a creation method on $class"; ## no critic qw(RequireLocalizedPunctuationVars) @ARGV = @used_args; $params{command_args} = [@args]; $params{command_name} = $cmd_name; defined $params{command_chain} or $params{command_chain} = []; my $self = $creation_method->($class, %params); push @{$self->command_chain}, $self; if ($cmd) { @ARGV = @args; my ($creation_method, $creation_method_name, $cmd_plugin); $cmd->can("_build_command_creation_method_name") and $creation_method_name = $cmd->_build_command_creation_method_name(\%params); $creation_method_name and $creation_method = $cmd->can($creation_method_name); if ($creation_method) { @cmd_create_params{qw(command_chain)} = @$self{qw(command_chain)}; $cmd_plugin = $creation_method->($cmd, %cmd_create_params); $self->{$self->command_execute_return_method_name} = [@{$call_indirect_method->($cmd_plugin, "command_execute_return_method_name")}]; } else { ($creation_method = first_result { defined $_ and $cmd->can($_) } @creation_chain) or croak "Can't find a creation method on " . $cmd; $cmd_plugin = $creation_method->($cmd); push @{$self->command_chain}, $cmd_plugin; my $cemn = $cmd_plugin->can("command_execute_method_name"); my $exec_fun = $cemn ? $cemn->() : $self->command_execute_method_name(); $self->command_execute_from_new and $self->{$self->command_execute_return_method_name} = [$call_required_method->($cmd_plugin, $exec_fun, \@ARGV, $self->command_chain)]; } } else { $self->command_execute_from_new and $self->{$self->command_execute_return_method_name} = [$call_indirect_method->($self, "command_execute_method_name", \@ARGV, $self->command_chain)]; } return $self; } # XXX should be an r/w attribute - can be renamed on loading ... sub execute_return { $_[0]->{execute_return} } 1; __END__ =pod =encoding UTF-8 =head1 NAME MooX::Cmd::Role - MooX cli app commands do this =head1 VERSION version 1.000 =head1 SYNOPSIS =head2 using role and want behavior as MooX::Cmd package MyFoo; with MooX::Cmd::Role; sub _build_command_execute_from_new { 1 } package main; my $cmd = MyFoo->new_with_cmd; =head2 using role and don't execute immediately 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(); =head2 explicit expression of some implicit stuff 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(); =head1 DESCRIPTION MooX::Cmd::Role is made for modern, flexible Moo style to tailor cli commands. =head2 command_args ARRAY-REF of args on command line =head2 command_chain ARRAY-REF of commands lead to this instance =head2 command_chain_end COMMAND accesses the finally detected command in chain =head2 command_name ARRAY-REF the name of the command lead to this command =head2 command_commands HASH-REF names of other commands =head2 command_base STRING base of command plugins =head2 command_execute_method_name STRING name of the method to invoke to execute a command, default "execute" =head2 command_execute_return_method_name STRING name of the attribute for storing the return value of execute =head2 command_creation_method_name STRING name of constructor =head2 command_creation_chain_methods ARRAY-REF names of methods to chain for creating object (from L) =head2 command_execute_from_new BOOL true when constructor shall invoke L, false otherwise =head2 new_with_cmd initializes by searching command line args for commands and invoke them =head2 execute_return returns the content of $self->{execute_return} =head1 SUPPORT =head2 Issues Please report bugs and feature requests on GitHub at L. =head2 IRC Join C<#web-simple> on C or message Getty directly. =head1 CONTRIBUTING Contributions are welcome! Please fork the repository and submit a pull request. =head1 AUTHOR Torsten Raudssus =head1 COPYRIGHT AND LICENSE This software is copyright (c) 2026 by Torsten Raudssus. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. =cut FailTestApp.pm100644001750001750 31715150637252 16343 0ustar00gettygetty000000000000MooX-Cmd-1.000/t/libpackage FailTestApp; use Moo; use MooX::Cmd execute_from_new => undef; around _build_command_execute_method_name => sub { "run" }; around _build_command_execute_from_new => sub { 0 }; sub run { @_ } 1; FirstTestApp.pm100644001750001750 26715150637252 16563 0ustar00gettygetty000000000000MooX-Cmd-1.000/t/libpackage FirstTestApp; BEGIN { my $moodel = $ENV{WHICH_MOODEL} || "Moo"; eval "use $moodel;"; $@ and die $@; $moodel->import; } use MooX::Cmd; sub execute { @_ } 1; ThirdTestApp.pm100644001750001750 52315150637252 16541 0ustar00gettygetty000000000000MooX-Cmd-1.000/t/libpackage ThirdTestApp; BEGIN { my $moodel = $ENV{WHICH_MOODEL} || "Moo"; eval "use $moodel;"; $@ and die $@; $moodel->import; } use MooX::Cmd execute_from_new => undef; around _build_command_execute_method_name => sub { "run" }; sub mach_mich_perwoll { goto \&MooX::Cmd::Role::_initialize_from_cmd; } sub run { @_ } 1; author-pod-syntax.t100644001750001750 45415150637252 16660 0ustar00gettygetty000000000000MooX-Cmd-1.000/t#!perl BEGIN { unless ($ENV{AUTHOR_TESTING}) { print qq{1..0 # SKIP these tests are for testing by the author\n}; exit } } # This file was automatically generated by Dist::Zilla::Plugin::PodSyntaxTests. use strict; use warnings; use Test::More; use Test::Pod 1.41; all_pod_files_ok(); Tester.pm100644001750001750 1652715150637252 16631 0ustar00gettygetty000000000000MooX-Cmd-1.000/lib/MooX/Cmdpackage MooX::Cmd::Tester; # ABSTRACT: MooX cli app commands tester our $VERSION = '1.000'; use strict; use warnings; require Exporter; use Test::More import => ['!pass']; use Package::Stash; use Capture::Tiny qw(:all); use parent qw(Test::Builder::Module Exporter); our @EXPORT = qw(test_cmd test_cmd_ok); our @EXPORT_OK = qw(test_cmd test_cmd_ok); our $TEST_IN_PROGRESS; my $CLASS = __PACKAGE__; BEGIN { *CORE::GLOBAL::exit = sub { return CORE::exit(@_) unless $TEST_IN_PROGRESS; MooX::Cmd::Tester::Exited->throw($_[0]); }; } sub result_class { 'MooX::Cmd::Tester::Result' } sub test_cmd { my ($app, $argv) = @_; my $result = _run_with_capture($app, $argv); my $exit_code = defined $result->{error} ? ((0 + $!) || -1) : 0; $result->{error} and eval { $result->{error}->isa('MooX::Cmd::Tester::Exited') } and $exit_code = ${$result->{error}}; result_class->new( { exit_code => $exit_code, %$result, } ); } sub test_cmd_ok { my $rv = test_cmd(@_); my $test_ident = $rv->app . " => [ " . join(" ", @{$_[1]}) . " ]"; ok(!$rv->error, "Everythink ok running cmd $test_ident") or diag($rv->error); # no error and cmd means, we're reasonable successful so far $rv and not $rv->error and $rv->cmd and $rv->cmd->command_name and ok($rv->cmd->command_commands->{$rv->cmd->command_name}, "found command at $test_ident"); $rv; } ## no critic qw(ProhibitSubroutinePrototypes) sub _capture_merged(&) { my $code = shift; my ($stdout, $stderr, $merged, $ok); if ($^O eq 'MSWin32') { ($stdout, $stderr, $ok) = tee { $code->(); }; $merged = $stdout . $stderr; } else { ($merged) = tee_merged { ($stdout, $stderr, $ok) = tee { $code->() }; }; } ($stdout, $stderr, $merged, $ok); } sub _run_with_capture { my ($app, $argv) = @_; my ($execute_rv, $cmd, $cmd_name, $error); my ($stdout, $stderr, $merged, $ok) = _capture_merged { eval { local $TEST_IN_PROGRESS = 1; local @ARGV = @$argv; my $tb = $CLASS->builder(); $cmd = ref $app ? $app : $app->new_with_cmd; ref $app and $app = ref $app; my $test_ident = "$app => [ " . join(" ", @$argv) . " ]"; ok($cmd->isa($app), "got a '$app' from new_with_cmd"); @$argv and defined($cmd_name = $cmd->command_name) and ok((grep { index($cmd_name, $_) != -1 } @$argv), "proper cmd name from $test_ident"); ok(scalar @{$cmd->command_chain} <= 1 + scalar @$argv, "\$#argv vs. command chain length testing $test_ident"); @$argv and ok($cmd->command_chain_end == $cmd->command_chain->[-1], "command_chain_end ok"); unless ($execute_rv = $cmd->execute_return) { my ($command_execute_from_new, $command_execute_method_name); my $cce = $cmd->can("command_chain_end"); $cce and $cce = $cce->($cmd); $cce and $command_execute_from_new = $cce->can("command_execute_from_new"); $command_execute_from_new and $command_execute_from_new = $command_execute_from_new->($cce); $command_execute_from_new or $command_execute_method_name = $cce->can('command_execute_method_name'); $command_execute_method_name and $execute_rv = [$cce->can($command_execute_method_name->($cce))->($cce)]; } 1; } or $error = 1; $@ and $error = $@; }; return { app => $app, cmd => $cmd, stdout => $stdout, stderr => $stderr, output => $merged, error => $error, execute_rv => $execute_rv, }; } { ## no critic qw(ProhibitMultiplePackages) package # no-index MooX::Cmd::Tester::Result; sub new { my ($class, $arg) = @_; bless $arg => $class; } } my $res = Package::Stash->new("MooX::Cmd::Tester::Result"); for my $attr (qw(app cmd stdout stderr output error execute_rv exit_code)) { $res->add_symbol('&' . $attr, sub { $_[0]->{$attr} }); } { ## no critic qw(ProhibitMultiplePackages) package # no-index MooX::Cmd::Tester::Exited; sub throw { my ($class, $code) = @_; defined $code or $code = 0; my $self = (bless \$code => $class); ## no critic qw(RequireCarping) die $self; } } 1; __END__ =pod =encoding UTF-8 =head1 NAME MooX::Cmd::Tester - MooX cli app commands tester =head1 VERSION version 1.000 =head1 SYNOPSIS use MooX::Cmd::Tester; use Test::More; use MyFoo; # basic tests as instance check, initialization check etc. is done there my $rv = test_cmd( MyFoo => [ command(s) option(s) ] ); like( $rv->stdout, qr/operation successful/, "Command performed" ); like( $rv->stderr, qr/patient dead/, "Deal with expected command error" ); is_deeply( $rv->execute_rv, \@expected_return_values, "got what I deserve?" ); cmp_ok( $rv->exit_code, "==", 0, "Command successful" ); =head1 DESCRIPTION The test coverage of most CLI apps is somewhere between poor and wretched. With the same approach as L comes MooX::Cmd::Tester to ease writing tests for CLI apps. =head2 result_class Builder for result class to use. Returns C by default. =head2 test_cmd my $rv = test_cmd( MyApp => \@argv ); test_cmd invokes the app with given argv as if would be invoked from command line and captures the output, the return values and exit code. Some minor tests are done to prove whether class matches, execute succeeds, command_name and command_chain are not totally scrambled. It returns an object with following attributes/accessors: =over =item app - Name of package of App =item cmd - Name of executed (1st level) command =item stdout - Content of stdout =item stderr - Content of stderr =item output - Content of merged stdout and stderr =item error - the exception thrown by running the application (if any) =item execute_rv - return values from execute =item exit_code - 0 on success, $! when error occurred and $! available, -1 otherwise =back =head2 test_cmd_ok my $rv = test_cmd_ok( MyApp => \@argv ); Runs C and expects it being successful - command_name must be in command_commands, etc. Returns the same object C returns. If an error occurred, no additional test is done (behavior as C). =head1 ACKNOWLEDGEMENTS MooX::Cmd::Tester is I by L from Ricardo Signes. In fact, I reused the entire design and adopt it to the requirements of MooX::Cmd. =head1 SUPPORT =head2 Issues Please report bugs and feature requests on GitHub at L. =head2 IRC Join C<#web-simple> on C or message Getty directly. =head1 CONTRIBUTING Contributions are welcome! Please fork the repository and submit a pull request. =head1 AUTHOR Torsten Raudssus =head1 COPYRIGHT AND LICENSE This software is copyright (c) 2026 by Torsten Raudssus. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. =cut OptionTestApp.pm100644001750001750 55015150637252 16737 0ustar00gettygetty000000000000MooX-Cmd-1.000/t/libpackage OptionTestApp; use strict; use warnings; BEGIN { my $moodel = $ENV{WHICH_MOODEL} || "Moo"; eval "use $moodel;"; $@ and die $@; $moodel->import; } use MooX::Cmd execute_from_new => undef; use MooX::Options; option in_doubt => ( is => "ro", negativable => 1, doc => "in doubt?", ); sub execute { @_ } 1; SecondTestApp.pm100644001750001750 46415150637252 16706 0ustar00gettygetty000000000000MooX-Cmd-1.000/t/libpackage SecondTestApp; BEGIN { my $moodel = $ENV{WHICH_MOODEL} || "Moo"; eval "use $moodel;"; $@ and die $@; $moodel->import; } use MooX::Cmd execute_from_new => 0; around _build_command_execute_method_name => sub { "run" }; sub run { @_ } sub was_haste { return $_[0]->{was_haste} } 1; ConfigAbbrevApp.pm100644001750001750 42015150637252 17152 0ustar00gettygetty000000000000MooX-Cmd-1.000/t/libpackage ConfigAbbrevApp; use strict; use warnings; BEGIN { my $moodel = $ENV{WHICH_MOODEL} || "Moo"; eval "use $moodel;"; $@ and die $@; $moodel->import; } use MooX::Cmd with_config_from_file => 1, with_abbrev_cmds => 1; sub execute { @_ } 1; 04-moox-configfromfile.t100644001750001750 353015150637252 17462 0ustar00gettygetty000000000000MooX-Cmd-1.000/t#!/usr/bin/perl use strict; use warnings; use Test::More; use Moo; use MooX::Cmd::Tester; use FindBin qw($Bin); use lib "$Bin/lib"; BEGIN { eval "use MooX::ConfigFromFile 0.006; use ConfigApp"; $@ and plan skip_all => "Need MooX::ConfigFromFile 0.006 -- $@" and exit(0); } diag("Testing MooX::Cmd version " . MooX::Cmd->VERSION . " using MooX::ConfigFromFile version " . MooX::ConfigFromFile->VERSION); my @tests = ( [[], "ConfigApp", "ConfigApp", {complicated_setting => {say => "Hello!"}}], [ [qw(check)], "ConfigApp", "ConfigApp::Cmd::Check", { unintialized_attribute => sub { time - $_[0] < 1 } } ], [ [qw(check it)], "ConfigApp", "ConfigApp::Cmd::Check::Cmd::It", {dedicated_setting => 1} ], ); SKIP: for (@tests) { my ($args, $class, $cmd_class, $attrs) = @{$_}; ref $args or $args = [split(' ', $args)]; my $rv = test_cmd($class => $args); #diag(explain($rv)); my $test_ident = "$class => " . join(" ", "[", @$args, "]"); ok($rv->cmd, "got cmd for $test_ident") or diag(explain($rv)); isa_ok($rv->cmd, $class) or skip("Cannot do attribute testing without command", 2); isa_ok($rv->cmd->command_chain_end, $cmd_class) or skip("Cannot do attribute testing without specific command", 1) if scalar @$args; my $cmd = scalar @$args ? $rv->cmd->command_chain_end : $rv->cmd; foreach my $k (keys %$attrs) { my $cmd_attr = $cmd->$k; ref $attrs->{$k} or is($attrs->{$k}, $cmd_attr, "Attribute $k for $test_ident"); "CODE" eq ref $attrs->{$k} and ok($attrs->{$k}->($cmd_attr), "Attribute $k ok for $test_ident"); ref $attrs->{$k} and "CODE" ne ref $attrs->{$k} and is_deeply($attrs->{$k}, $cmd_attr, "Attribute $k for $test_ident"); } } done_testing; 06-abbrev-configfromfile.t100644001750001750 405315150637252 17744 0ustar00gettygetty000000000000MooX-Cmd-1.000/t#!/usr/bin/perl use strict; use warnings; use Test::More; use Moo; use MooX::Cmd::Tester; use FindBin qw($Bin); use lib "$Bin/lib"; BEGIN { eval "use Text::Abbrev; use MooX::ConfigFromFile 0.006; use ConfigAbbrevApp"; $@ and plan skip_all => "Need Text::Abbrev and MooX::ConfigFromFile 0.006 -- $@" and exit(0); } diag( "Testing MooX::Cmd version " . MooX::Cmd->VERSION . " using MooX::ConfigFromFile version " . MooX::ConfigFromFile->VERSION . " and Text::Abbrev version " . Text::Abbrev->VERSION); my @tests = ( [[], "ConfigAbbrevApp", "ConfigAbbrevApp", {}], [ [qw(thuruksp)], "ConfigAbbrevApp", "ConfigAbbrevApp::Cmd::ThuruksPride", { race => "Split", security_level => "Core" } ], [ [qw(thuruksb)], "ConfigAbbrevApp", "ConfigAbbrevApp::Cmd::ThuruksBeard", { race => "Split", security_level => "Border" } ], ); SKIP: for (@tests) { my ($args, $class, $cmd_class, $attrs) = @{$_}; ref $args or $args = [split(' ', $args)]; my $rv = test_cmd($class => $args); #diag(explain($rv)); my $test_ident = "$class => " . join(" ", "[", @$args, "]"); ok($rv->cmd, "got cmd for $test_ident") or diag(explain($rv)); isa_ok($rv->cmd, $class) or skip("Cannot do attribute testing without command", 2); isa_ok($rv->cmd->command_chain_end, $cmd_class) or skip("Cannot do attribute testing without specific command", 1) if scalar @$args; my $cmd = scalar @$args ? $rv->cmd->command_chain_end : $rv->cmd; foreach my $k (keys %$attrs) { my $cmd_attr = $cmd->$k; ref $attrs->{$k} or is($attrs->{$k}, $cmd_attr, "Attribute $k for $test_ident"); "CODE" eq ref $attrs->{$k} and ok($attrs->{$k}->($cmd_attr), "Attribute $k ok for $test_ident"); ref $attrs->{$k} and "CODE" ne ref $attrs->{$k} and is_deeply($attrs->{$k}, $cmd_attr, "Attribute $k for $test_ident"); } } done_testing; Cmd000755001750001750 015150637252 16061 5ustar00gettygetty000000000000MooX-Cmd-1.000/t/lib/ConfigAppCheck.pm100644001750001750 60115150637252 17551 0ustar00gettygetty000000000000MooX-Cmd-1.000/t/lib/ConfigApp/Cmdpackage ConfigApp::Cmd::Check; use strict; use warnings; BEGIN { my $moodel = $ENV{WHICH_MOODEL} || "Moo"; eval "use $moodel;"; $@ and die $@; $moodel->import; } use MooX::Cmd; has unintialized_attribute => ( is => "ro", builder => "_build_unintialized_attribute", lazy => 1 ); sub _build_unintialized_attribute { time } sub execute { @_ } 1; Cmd000755001750001750 015150637252 16566 5ustar00gettygetty000000000000MooX-Cmd-1.000/t/lib/ThirdTestAppFoo.pm100644001750001750 34015150637252 17764 0ustar00gettygetty000000000000MooX-Cmd-1.000/t/lib/ThirdTestApp/Cmdpackage ThirdTestApp::Cmd::Foo; BEGIN { my $moodel = $ENV{WHICH_MOODEL} || "Moo"; eval "use $moodel;"; $@ and die $@; $moodel->import; } sub _build_command_execute_method_name { "run" } sub run { @_ } 1; Cmd000755001750001750 015150637252 16603 5ustar00gettygetty000000000000MooX-Cmd-1.000/t/lib/FirstTestAppTest.pm100644001750001750 30215150637252 20173 0ustar00gettygetty000000000000MooX-Cmd-1.000/t/lib/FirstTestApp/Cmdpackage FirstTestApp::Cmd::Test; BEGIN { my $moodel = $ENV{WHICH_MOODEL} || "Moo"; eval "use $moodel;"; $@ and die $@; $moodel->import; } use MooX::Cmd; sub execute { @_ } 1; Cmd000755001750001750 015150637252 16727 5ustar00gettygetty000000000000MooX-Cmd-1.000/t/lib/SecondTestAppcwo.pm100644001750001750 57415150637252 20203 0ustar00gettygetty000000000000MooX-Cmd-1.000/t/lib/SecondTestApp/Cmdpackage SecondTestApp::Cmd::cwo; BEGIN { my $moodel = $ENV{WHICH_MOODEL} || "Moo"; eval "use $moodel;"; $@ and die $@; $moodel->import; } use MooX::Cmd execute_return_method_name => 'run_result', creation_method_name => "mach_mich_neu", execute_from_new => 1; around _build_command_execute_method_name => sub { "run" }; sub run { @_ } 1; ifc.pm100644001750001750 55615150637252 20154 0ustar00gettygetty000000000000MooX-Cmd-1.000/t/lib/SecondTestApp/Cmdpackage SecondTestApp::Cmd::ifc; BEGIN { my $moodel = $ENV{WHICH_MOODEL} || "Moo"; eval "use $moodel;"; $@ and die $@; $moodel->import; __PACKAGE__->can("with")->("MooX::Cmd::Role"); } around _build_command_execute_method_name => sub { "run" }; around _build_command_execute_from_new => sub { 1 }; sub run { @_ } eval "use MooX::Cmd;"; 1; Role000755001750001750 015150637252 15533 5ustar00gettygetty000000000000MooX-Cmd-1.000/lib/MooX/CmdAbbrevCmds.pm100644001750001750 334515150637252 20246 0ustar00gettygetty000000000000MooX-Cmd-1.000/lib/MooX/Cmd/Rolepackage MooX::Cmd::Role::AbbrevCmds; # ABSTRACT: Text::Abbrev support role for MooX::Cmd our $VERSION = '1.000'; use strict; use warnings; use Text::Abbrev; use Moo::Role; requires "command_commands"; around _build_command_commands => sub { my $next = shift; my $class = shift; my $params = shift; my $cmd_cmds = $class->$next($params, @_); my %abbrevs = abbrev keys %$cmd_cmds; my %cmd_cmds = map { $_ => $cmd_cmds->{$abbrevs{$_}} } keys %abbrevs; return \%cmd_cmds; }; 1; __END__ =pod =encoding UTF-8 =head1 NAME MooX::Cmd::Role::AbbrevCmds - Text::Abbrev support role for MooX::Cmd =head1 VERSION version 1.000 =head1 DESCRIPTION When this role is applied, commands can be called by any unambiguous prefix. For example, if your app has commands C and C, typing C will match C. Uses L internally. Compose into your top-level command class alongside L: package MyApp; use Moo; use MooX::Cmd with_abbrev_cmds => 1; Or apply the role explicitly: package MyApp; use Moo; with 'MooX::Cmd::Role'; with 'MooX::Cmd::Role::AbbrevCmds'; =head1 SUPPORT =head2 Issues Please report bugs and feature requests on GitHub at L. =head2 IRC Join C<#web-simple> on C or message Getty directly. =head1 CONTRIBUTING Contributions are welcome! Please fork the repository and submit a pull request. =head1 AUTHOR Torsten Raudssus =head1 COPYRIGHT AND LICENSE This software is copyright (c) 2026 by Torsten Raudssus. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. =cut Cmd000755001750001750 015150637252 16764 5ustar00gettygetty000000000000MooX-Cmd-1.000/t/lib/OptionTestAppOops.pm100644001750001750 34215150637252 20361 0ustar00gettygetty000000000000MooX-Cmd-1.000/t/lib/OptionTestApp/Cmdpackage OptionTestApp::Cmd::Oops; BEGIN { my $moodel = $ENV{WHICH_MOODEL} || "Moo"; eval "use $moodel;"; $@ and die $@; $moodel->import; } sub _build_command_execute_method_name { "run" } sub run { @_ } 1; Cmd000755001750001750 015150637252 16367 5ustar00gettygetty000000000000MooX-Cmd-1.000/t/lib/FailTestAppnothing.pm100644001750001750 4715150637252 20474 0ustar00gettygetty000000000000MooX-Cmd-1.000/t/lib/FailTestApp/Cmdpackage FailTestApp::Cmd::nothing; 1; etc000755001750001750 015150637252 13252 5ustar00gettygetty000000000000MooX-Cmd-1.00004-moox-configfromfile.t.json100644001750001750 7015150637252 20676 0ustar00gettygetty000000000000MooX-Cmd-1.000/etc{ "complicated_setting": { "say": "Hello!" } } primary.pm100644001750001750 56015150637252 21126 0ustar00gettygetty000000000000MooX-Cmd-1.000/t/lib/OptionTestApp/Cmdpackage OptionTestApp::Cmd::primary; use strict; use warnings; BEGIN { my $moodel = $ENV{WHICH_MOODEL} || "Moo"; eval "use $moodel;"; $@ and die $@; $moodel->import; } use MooX::Cmd; use MooX::Options; option serious => ( is => "ro", negativable => 1, required => 0, doc => "serious?", ); sub execute { @_ } 1; 06-abbrev-configfromfile.t.json100644001750001750 3015150637252 21153 0ustar00gettygetty000000000000MooX-Cmd-1.000/etc{ "race": "Split" } ConfigFromFile.pm100644001750001750 344015150637252 21063 0ustar00gettygetty000000000000MooX-Cmd-1.000/lib/MooX/Cmd/Rolepackage MooX::Cmd::Role::ConfigFromFile; # ABSTRACT: MooX::ConfigFromFile support role for MooX::Cmd our $VERSION = '1.000'; use strict; use warnings; use Moo::Role; requires "config_prefixes"; around _build_config_prefixes => sub { my $next = shift; my $class = shift; my $params = shift; my $cfg_pfxs = $class->$next($params, @_); ref $params->{command_chain} eq "ARRAY" and push @{$cfg_pfxs}, grep { defined $_ } map { $_->command_name } grep { $_->can("command_name") } @{$params->{command_chain}}; return $cfg_pfxs; }; 1; __END__ =pod =encoding UTF-8 =head1 NAME MooX::Cmd::Role::ConfigFromFile - MooX::ConfigFromFile support role for MooX::Cmd =head1 VERSION version 1.000 =head1 DESCRIPTION Extends L config prefix support to include the current command chain. Each command name in the chain is appended to the config prefixes, allowing per-command configuration file sections. Enable via L: package MyApp; use Moo; use MooX::Cmd with_config_from_file => 1; This will automatically compose both L and this role into your command classes. =head1 SEE ALSO L =head1 SUPPORT =head2 Issues Please report bugs and feature requests on GitHub at L. =head2 IRC Join C<#web-simple> on C or message Getty directly. =head1 CONTRIBUTING Contributions are welcome! Please fork the repository and submit a pull request. =head1 AUTHOR Torsten Raudssus =head1 COPYRIGHT AND LICENSE This software is copyright (c) 2026 by Torsten Raudssus. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. =cut Cmd000755001750001750 015150637252 16055 5ustar00gettygetty000000000000MooX-Cmd-1.000/t/lib/AbbrevAppThuruksBeard.pm100644001750001750 150315150637252 21155 0ustar00gettygetty000000000000MooX-Cmd-1.000/t/lib/AbbrevApp/Cmdpackage AbbrevApp::Cmd::ThuruksBeard; use strict; use warnings; BEGIN { my $moodel = $ENV{WHICH_MOODEL} || "Moo"; eval "use $moodel;"; $@ and die $@; $moodel->import; } use MooX::Cmd; has race => is => ro => default => "Split"; has security_level => is => ro => default => "Border"; has planets => is => ro => predicate => 1 => default => "1"; has stations => is => ro => predicate => 1 => default => "13"; has asteroids => is => ro => predicate => 1 => default => "0"; has north_gate => is => ro => predicate => 1 => default => "FamilyRhonkar"; has south_gate => is => ro => predicate => 1 => default => "HatikvahsFaith"; has east_gate => is => ro => predicate => 1; has west_gate => is => ro => predicate => 1 => default => "CompanyPride"; sub execute { @_ } 1; ThuruksPride.pm100644001750001750 147415150637252 21212 0ustar00gettygetty000000000000MooX-Cmd-1.000/t/lib/AbbrevApp/Cmdpackage AbbrevApp::Cmd::ThuruksPride; use strict; use warnings; BEGIN { my $moodel = $ENV{WHICH_MOODEL} || "Moo"; eval "use $moodel;"; $@ and die $@; $moodel->import; } use MooX::Cmd; has race => is => ro => default => "Split"; has security_level => is => ro => default => "Core"; has planets => is => ro => predicate => 1 => default => "3"; has stations => is => ro => predicate => 1 => default => "11"; has asteroids => is => ro => predicate => 1 => default => "1"; has north_gate => is => ro => predicate => 1 => default => "FamilyZein"; has south_gate => is => ro => predicate => 1 => default => "RhonkarsFire"; has east_gate => is => ro => predicate => 1 => default => "CompanyPride"; has west_gate => is => ro => predicate => 1; sub execute { @_ } 1; Cmd000755001750001750 015150637252 17601 5ustar00gettygetty000000000000MooX-Cmd-1.000/t/lib/ConfigApp/Cmd/CheckIt.pm100644001750001750 50615150637252 20634 0ustar00gettygetty000000000000MooX-Cmd-1.000/t/lib/ConfigApp/Cmd/Check/Cmdpackage ConfigApp::Cmd::Check::Cmd::It; use strict; use warnings; BEGIN { my $moodel = $ENV{WHICH_MOODEL} || "Moo"; eval "use $moodel;"; $@ and die $@; $moodel->import; } use MooX::Cmd with_config_from_file => 1; has dedicated_setting => ( is => "ro", required => 1 ); sub execute { @_ } 1; nocreatable.pm100644001750001750 23115150637252 21320 0ustar00gettygetty000000000000MooX-Cmd-1.000/t/lib/FailTestApp/Cmdpackage FailTestApp::Cmd::nocreatable; use Moo; with "MooX::Cmd::Role"; around _build_command_creation_chain_methods => sub { }; sub execute { } 1; uncreatable.pm100644001750001750 23415150637252 21331 0ustar00gettygetty000000000000MooX-Cmd-1.000/t/lib/FailTestApp/Cmdpackage FailTestApp::Cmd::uncreatable; use Moo; with "MooX::Cmd::Role"; around _build_command_creation_chain_methods => sub { [] }; sub execute { } 1; 04-moox-configfromfile.t-check.json100644001750001750 4715150637252 21755 0ustar00gettygetty000000000000MooX-Cmd-1.000/etc{ "unintialized_attribute": 4711 } Cmd000755001750001750 015150637252 20225 5ustar00gettygetty000000000000MooX-Cmd-1.000/t/lib/FirstTestApp/Cmd/TestTest.pm100644001750001750 27615150637252 21627 0ustar00gettygetty000000000000MooX-Cmd-1.000/t/lib/FirstTestApp/Cmd/Test/Cmdpackage FirstTestApp::Cmd::Test::Cmd::Test; BEGIN { my $moodel = $ENV{WHICH_MOODEL} || "Moo"; eval "use $moodel;"; $@ and die $@; $moodel->import; } sub execute { @_ } 1; Cmd000755001750001750 015150637252 17203 5ustar00gettygetty000000000000MooX-Cmd-1.000/t/lib/ConfigAbbrevAppThuruksBeard.pm100644001750001750 130615150637252 22304 0ustar00gettygetty000000000000MooX-Cmd-1.000/t/lib/ConfigAbbrevApp/Cmdpackage ConfigAbbrevApp::Cmd::ThuruksBeard; use strict; use warnings; BEGIN { my $moodel = $ENV{WHICH_MOODEL} || "Moo"; eval "use $moodel;"; $@ and die $@; $moodel->import; } use MooX::Cmd with_config_from_file => 1; has race => is => ro => required => 1; has security_level => is => ro => required => 1; has planets => is => ro => required => 1; has stations => is => ro => required => 1; has asteroids => is => ro => required => 1; has north_gate => is => ro => predicate => 1; has south_gate => is => ro => predicate => 1; has east_gate => is => ro => predicate => 1; has west_gate => is => ro => predicate => 1; sub execute { @_ } 1; ThuruksPride.pm100644001750001750 130615150637252 22332 0ustar00gettygetty000000000000MooX-Cmd-1.000/t/lib/ConfigAbbrevApp/Cmdpackage ConfigAbbrevApp::Cmd::ThuruksPride; use strict; use warnings; BEGIN { my $moodel = $ENV{WHICH_MOODEL} || "Moo"; eval "use $moodel;"; $@ and die $@; $moodel->import; } use MooX::Cmd with_config_from_file => 1; has race => is => ro => required => 1; has security_level => is => ro => required => 1; has planets => is => ro => required => 1; has stations => is => ro => required => 1; has asteroids => is => ro => required => 1; has north_gate => is => ro => predicate => 1; has south_gate => is => ro => predicate => 1; has east_gate => is => ro => predicate => 1; has west_gate => is => ro => predicate => 1; sub execute { @_ } 1; 04-moox-configfromfile.t-check-it.json100644001750001750 3715150637252 22366 0ustar00gettygetty000000000000MooX-Cmd-1.000/etc{ "dedicated_setting": 1 } 06-abbrev-configfromfile.t-thuruksbeard.json100644001750001750 31315150637252 23700 0ustar00gettygetty000000000000MooX-Cmd-1.000/etc{ "security_level": "Border", "planets": "1", "stations": "13", "asteroids": "0", "north_gate": "FamilyRhonkar", "south_gate": "HatikvahsFaith", "west_gate": "CompanyPride" } 06-abbrev-configfromfile.t-thurukspride.json100644001750001750 30415150637252 23726 0ustar00gettygetty000000000000MooX-Cmd-1.000/etc{ "security_level": "Core", "planets": "3", "stations": "11", "asteroids": "1", "north_gate": "FamilyZein", "south_gate": "RhonkarsFire", "east_gate": "CompanyPride" } Cmd000755001750001750 015150637252 21152 5ustar00gettygetty000000000000MooX-Cmd-1.000/t/lib/OptionTestApp/Cmd/primarysecondary.pm100644001750001750 57215150637252 23623 0ustar00gettygetty000000000000MooX-Cmd-1.000/t/lib/OptionTestApp/Cmd/primary/Cmdpackage OptionTestApp::Cmd::primary::Cmd::secondary; use strict; use warnings; BEGIN { my $moodel = $ENV{WHICH_MOODEL} || "Moo"; eval "use $moodel;"; $@ and die $@; $moodel->import; } use MooX::Cmd; use MooX::Options; option sure => ( is => "ro", negativable => 1, required => 1, doc => "sure?", ); sub execute { @_ } 1;