MooseX-App-1.39/000755 000765 000024 00000000000 13161707310 013661 5ustar00marosstaff000000 000000 MooseX-App-1.39/Changes000644 000765 000024 00000015621 13110643415 015160 0ustar00marosstaff000000 000000 Release history for Perl module MooseX::App 1.38 2017-06-20 - Cleanups (get rid of smartmatch, inentation, documentation, tests) - Also handle =head[2-4] tags when processing pod (#47) - Subcommands (based on work by Yanick Champoux) 1.37 2016-11-13 - Refactor the way values are parsed from @ARGV - Rework boolean negation - Add developer checks 1.36 2016-10-11 - Documentation - Set correct encoding on STDERR - Fix order of options (fixed by J.R. Mash) - Replace dashes in variable names with underscores in bash completion (implemented byTina Müller) - Do not autocomplete autocomplete itself (implemented by Lisa Hare) - Create correct documentation for options with cmd_split - Rename hints key to clarify purpose - Add ability to negate boolean options (implemented by Marc Logghe) - Spelling fixes github#39 (fixed by Gregor Herrmann) - Retain original order of elements from @ARGV 1.35 2016-04-02 - Spelling fixes RT112234 (fixed by Gregor Herrmann) - Documentation - Allow to pass ARGV directly to constructor - use namespace::autoclean (reported by Mohammad S Anwar) - Dist housekeeping 1.34 2016-02-21 - Do not accept invalid character in Term plugin - Fix RT112156: Command class lacking attribute metarole (reported by Marc Logghe) - Apply Spelling fixes RT105717 (fixed by Gregor Herrmann) - Add permute option to specify multiple values with one attribute key - Fix imports (fixed by Alexander Stoddard) - Documentation 1.33 2015-04-17 - Fix failing tests - Fix manifest 1.32 2015-03-21 - Improved Term Plugin (History, Delete, Pasting, Pos1/End, Cursors) - Documentation - Added app_command_register - Errors are now printed on STDERR - Disable fuzzy match for single letter parameters - Use proper exit codes if errors occur - Add tests for subprocesses - Add MutexGroup plugin (implemented by Hunter McMillen) - Add Depends plugin (implemented by Hunter McMillen) 1.31 2015-02-08 - Dist cleanup (done by Sergey Romanov) - Moose cleanups (done by Sawyer X) - Fixed TERM plugin input - Coercion for ENV variables (implemented by Roman F.) - Refactor handling of boolean values - Allow for empty values - Add cmd_count option for counter attributes 1.30 2014-08-24 - Better error message if command was not specified - Help improved - Term plugin - Deprecate Env plugin; Now in core - Fix broken usage in M::A::Simple - Fix documentation being parsed called multiple times 1.29 2014-08-05 - Documentation improvements and fixups - Better error messages if type constraints fail - Better suggestions in case of errors - Handle enum type constraints in usage info - Display application documentation 1.28 2014-03-25 - Fix failing tests (reported by Michael Greb and Dagfinn Ilmari Mannsåker) 1.27 2014-03-02 - Fix warnings on warnings on 5.18 again - Documentation - Fix spelling (fixed by Gregor Herrmann) 1.26 2014-02-24 - Fix failing tests 1.25 2014-02-23 - Allow multiple command namespaces (implemented by Thilo Fester) - Documentation 1.24 2014-02-14 - Fix POD warnings (fixed by David Golden) - Always reuse existing MooseX::App::ParsedArgv instances - Parse @ARGV as soon as possible - Fix Win32 colorisation issues (fixed by J.R. Mash) - Add app_prefer_commandline option 1.23 2014-01-27 - Documentation - Manual plugin - More inheritance tests - Cleanup deprecated code 1.22 2013-05-24 - Silence experimental::smartmatch warnings on 5.18 (fixed by Mike Doherty) 1.21 2013-04-13 - Fix option sorting - Fix parsing of positional parameters 1.20 2013-04-08 - Add cmd_split and cmd_position option - Fixed parameter position (fixed by Yanick Champoux) - app_strict option to set if app should terminate when unknown parameters or options are supplied 1.19 2013-03-28 - Fixed failing tests - Fixed bug that was triggered by Moose 2.0800 - Fixed on MSWin 1.18 2013-03-24 - Added positional parameters with 'parameter' keyword (Attention: this change might break things if you used to work with @extra) - Parameters are handled in the meta class - Usage meta class methods refactored 1.17 2013-03-06 - Fix failing tests 1.16 2013-02-27 - Better license parsing - Fix failing tests - Use Class::Load instead of Class::MOP to load classes - Remove MooseX::Getopt dependency. Parse @ARGV ourself - Renamed meta class methods to use single prefix - Moved meta class methods to attribute meta class - Much more tests (95% statement and 90% total coverage) - Better error handling for Environment plugin 1.15 2013-01-18 - Fix wrong attribute initialisation order 1.14 2013-01-15 - Fix failing test - Update documentation - Optional usage information from POD (implemented by Yanick Champoux) - app_fuzzy now defaults to true - Version plugin prints license and copyright 1.13 2013-01-11 - Fix failing test - Update documentation 1.12 2013-01-10 - Fix failing test - Fix pod (Andrew Jones) 1.11 2013-01-08 - Parse DistZilla ABSTRACT for documentation - Improve tutorial and fix typo (fixed by George Hartzell) - Saner bash completion and version plugin - Fix fuzzy command and attribute matching - Deprecate fuzzy plugin, use typo plugin instead - Handle shell character encodings - More tests 1.10 2013-01-07 - Fix bash completion plugin (fixed by Steve Nolte) 1.09 2012-11-22 - Fix failing load test 1.08 2012-11-17 - Refactor object initialisation - Fix missing bash-completion prefix (fixed by Steve Nolte) - Require latest MooseX::Getopt (fixed by Steve Nolte) - Fix Plugin::Version docs RT81186 (fixed by Michael G) - Update documentation 1.07 2012-08-22 - Fix failing load tests 1.06 2012-08-20 - Single command interface (MooseX::App::Simple) - Fuzzy command matching plugin - Only lowercase command names - Environment plugin - Version plugin - Various cleanups 1.05 2012-06-04 - Fix broken load tests - Join M::A::Meta::Attribute::Base and M::A::Meta::Attribute::Option 1.04 2012-06-02 - Fix bugs in BashCompletion plugin - Remove code duplication - Fix --help flag in command classes - Fix pod to text conversion 1.03 2012-06-02 - Do not expose all attributes as options but only those defined via 'option' keyword - More tests - Internal changes (move methods to meta class, calculate loadable commands only once, ...) - Fix various bugs 1.02 2012-04-15 - Fix command usage generation bug - Automatically apply MooseX-Getopt attribute traits - Rename command_tag to cmd_tag attribute 1.01 2012-04-12 - Fix text failures - Fix Pod - Add missing tutorials to manifest 1.00 2012-04-07 - Initial version MooseX-App-1.39/LICENCE000644 000765 000024 00000050101 11014620472 014641 0ustar00marosstaff000000 000000 Terms of Perl 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 General Public License (GPL) Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc. 675 Mass Ave, Cambridge, MA 02139, USA. Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU 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. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Library General Public License instead.) You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), 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 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 show them these terms so they know 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. Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all. 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 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 derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you". Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does. 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 License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program. 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. 2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change. b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License. c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary 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 License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program. In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 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 Sections 1 and 2 above on a medium customarily used for software interchange; or, b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.) The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code. 4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing 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 for copying, distributing or modifying the Program or works based on it. 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. You are not responsible for enforcing compliance by third parties to this License. 7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 9. 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 this 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 this License, you may choose any version ever published by the Free Software Foundation. 10. 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 11. 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. 12. 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 --------------------------------------------------------------------------- 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. - "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 ftp.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) accompany any non-standard executables with their corresponding Standard Version executables, giving the non-standard executables non-standard names, and clearly documenting 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. 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 whomever generated them, and may be sold commercially, and may be aggregated with this Package. 7. C or perl subroutines supplied by you and linked into this Package shall not be considered part of this Package. 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 MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. The End MooseX-App-1.39/MANIFEST000644 000765 000024 00000006615 13161707144 015027 0ustar00marosstaff000000 000000 Changes inc/Module/Install.pm inc/Module/Install/AuthorRequires.pm inc/Module/Install/Base.pm inc/Module/Install/Can.pm inc/Module/Install/Fetch.pm inc/Module/Install/Makefile.pm inc/Module/Install/Metadata.pm inc/Module/Install/ReadmeFromPod.pm inc/Module/Install/Win32.pm inc/Module/Install/WriteAll.pm lib/MooseX/App.pm lib/MooseX/App/Command.pm lib/MooseX/App/Exporter.pm lib/MooseX/App/Message/Block.pm lib/MooseX/App/Message/BlockColor.pm lib/MooseX/App/Message/Envelope.pm lib/MooseX/App/Meta/Role/Attribute/Option.pm lib/MooseX/App/Meta/Role/Class/Base.pm lib/MooseX/App/Meta/Role/Class/Command.pm lib/MooseX/App/Meta/Role/Class/Documentation.pm lib/MooseX/App/Meta/Role/Class/Simple.pm lib/MooseX/App/ParsedArgv.pm lib/MooseX/App/ParsedArgv/Element.pm lib/MooseX/App/ParsedArgv/Value.pm lib/MooseX/App/Plugin/BashCompletion.pm lib/MooseX/App/Plugin/BashCompletion/Command.pm lib/MooseX/App/Plugin/BashCompletion/Meta/Class.pm lib/MooseX/App/Plugin/Color.pm lib/MooseX/App/Plugin/Color/Meta/Class.pm lib/MooseX/App/Plugin/Config.pm lib/MooseX/App/Plugin/Config/Meta/Class.pm lib/MooseX/App/Plugin/ConfigHome.pm lib/MooseX/App/Plugin/ConfigHome/Meta/Class.pm lib/MooseX/App/Plugin/Depends.pm lib/MooseX/App/Plugin/Depends/Meta/Attribute.pm lib/MooseX/App/Plugin/Depends/Meta/Class.pm lib/MooseX/App/Plugin/Env.pm lib/MooseX/App/Plugin/Fuzzy.pm lib/MooseX/App/Plugin/Man.pm lib/MooseX/App/Plugin/Man/Command.pm lib/MooseX/App/Plugin/Man/Meta/Class.pm lib/MooseX/App/Plugin/MutexGroup.pm lib/MooseX/App/Plugin/MutexGroup/Meta/Attribute.pm lib/MooseX/App/Plugin/MutexGroup/Meta/Class.pm lib/MooseX/App/Plugin/Term.pm lib/MooseX/App/Plugin/Term/Meta/Attribute.pm lib/MooseX/App/Plugin/Term/Meta/Class.pm lib/MooseX/App/Plugin/Typo.pm lib/MooseX/App/Plugin/Typo/Meta/Class.pm lib/MooseX/App/Plugin/Version.pm lib/MooseX/App/Plugin/Version/Command.pm lib/MooseX/App/Plugin/Version/Meta/Class.pm lib/MooseX/App/Role.pm lib/MooseX/App/Role/Base.pm lib/MooseX/App/Role/Common.pm lib/MooseX/App/Simple.pm lib/MooseX/App/Tutorial.pod lib/MooseX/App/Utils.pm lib/MooseX/App/WritingPlugins.pod LICENCE Makefile.PL MANIFEST This list of files META.yml README t/00_load.t t/01_basic.t t/02_meta.t t/03_utils.t t/04_plugin_config.t t/05_extended.t t/06_env.t t/07_single.t t/08_plugin_various.t t/09_classes.t t/10_plugin_mutexgroup.t t/11_process.t t/12_plugin_depends.t t/13_rt_112156.t t/14_gh_45.t t/15_subcommands.t t/16_rt122946.t t/config.pl t/example/test01.pl t/example/test02.pl t/example/test03.pl t/example/test04.pl t/example/test05.pl t/example/test06.pl t/example/test07.pl t/example/test08.pl t/testlib/Test01.pm t/testlib/Test01/CommandA.pm t/testlib/Test01/CommandB.pm t/testlib/Test01/CommandC1.pm t/testlib/Test01/CommandD.pm t/testlib/Test02.pm t/testlib/Test02/Command/Error.pm t/testlib/Test02/Command/Record.pm t/testlib/Test02/Command/Required.pm t/testlib/Test02/MoreCommands/Test.pm t/testlib/Test03.pm t/testlib/Test03/AnotherCommand.pm t/testlib/Test03/BrokenCommand.pm t/testlib/Test03/DifferentCommand.pm t/testlib/Test03/ExtraCommand.pm t/testlib/Test03/Role/TestRole.pm t/testlib/Test03/SomeCommand.pm t/testlib/Test03/YetAnotherCommand.pm t/testlib/Test03CommandBase.pm t/testlib/Test04.pm t/testlib/Test04Base.pm t/testlib/Test05.pm t/testlib/Test06.pm t/testlib/Test06/CommandA.pm t/testlib/Test06/CommandB.pm t/testlib/Test06/CommandD.pm t/testlib/Test07.pm t/testlib/Test08.pm TODO xt/perlcritic.t xt/pod.t xt/podcoverage.t xt/podstyle.t MooseX-App-1.39/META.yml000644 000765 000024 00000001734 13052770605 015145 0ustar00marosstaff000000 000000 --- abstract: 'Write user-friendly command line apps with even less suffering' author: - 'Maroš Kollár' build_requires: ExtUtils::MakeMaker: 6.59 Test::Most: 0 Test::NoWarnings: 0 configure_requires: ExtUtils::MakeMaker: 6.59 distribution_type: module dynamic_config: 1 generated_by: 'Module::Install version 1.16' license: perl meta-spec: url: http://module-build.sourceforge.net/META-spec-v1.4.html version: 1.4 name: MooseX-App no_index: directory: - inc - t - xt recommends: File::HomeDir: 0 IO::Interactive: 0 Term::ANSIColor: 0 Term::ReadKey: 0 Text::WagnerFischer: 0 requires: Config::Any: 0 List::Util: '1.44' Module::Pluggable: 0 Moose: '2.00' MooseX::Types::Path::Class: 0 Path::Class: 0 Pod::Elemental: 0 namespace::autoclean: 0 perl: 5.10.0 resources: bugtracker: https://github.com/maros/MooseX-App/issues license: http://dev.perl.org/licenses/ repository: git://github.com/maros/MooseX-App.git version: 1.3701 MooseX-App-1.39/Makefile.PL000644 000765 000024 00000002771 13110107114 015630 0ustar00marosstaff000000 000000 # Load the Module::Install bundled in ./inc/ use lib "."; use strict; use warnings; use inc::Module::Install 1.05; my $from = 'lib/MooseX/App.pm'; # Define metadata name 'MooseX-App'; all_from $from; readme_from $from; perl_version '5.010'; # Specific dependencies requires 'Moose' => '2.00'; requires 'namespace::autoclean' => 0; requires 'Module::Pluggable' => 0; requires 'Path::Class' => 0; requires 'MooseX::Types::Path::Class' => 0; requires 'Config::Any' => 0; requires 'List::Util' => '1.44'; requires 'Pod::Elemental' => 0; recommends 'IO::Interactive' => 0; recommends 'Term::ReadKey' => 0; recommends 'Term::ANSIColor' => 0; recommends 'File::HomeDir' => 0; recommends 'Text::WagnerFischer' => 0; if ($^O eq 'MSWin32') { recommends 'Win32::Console::ANSI'; } build_requires 'Test::Most' => 0; build_requires 'Test::NoWarnings' => 0; author_requires 'Test::Pod' => '1.14'; author_requires 'Test::Pod::Coverage' => '1.04'; author_requires 'Test::Perl::Critic' => 0; author_requires 'Module::Install::ReadmeFromPod'=> 0; repository 'git://github.com/maros/MooseX-App.git'; bugtracker 'https://github.com/maros/MooseX-App/issues'; WriteAll;MooseX-App-1.39/README000644 000765 000024 00000036641 13110107052 014542 0ustar00marosstaff000000 000000 NAME MooseX::App - Write user-friendly command line apps with even less suffering SYNOPSIS In your base class: package MyApp; use MooseX::App qw(Color); option 'global_option' => ( is => 'rw', isa => 'Bool', documentation => q[Enable this to do fancy stuff], ); # Global option has 'private' => ( is => 'rw', ); # not exposed Write multiple command classes (If you have only a single command class you should use MooseX::App::Simple instead). Packackes in the namespace may be deeply nested. package MyApp::SomeCommand; use MooseX::App::Command; # important (also imports Moose) extends qw(MyApp); # optional, only if you want to use global options from base class # Positional parameter parameter 'some_parameter' => ( is => 'rw', isa => 'Str', required => 1, documentation => q[Some parameter that you need to supply], ); option 'some_option' => ( is => 'rw', isa => 'Int', required => 1, documentation => q[Very important option!], ); # Option sub run { my ($self) = @_; # Do something } And then you need a simple wrapper script (called eg. myapp): #!/usr/bin/env perl use MyApp; MyApp->new_with_command->run; On the command line: bash$ myapp help usage: myapp [long options...] myapp help global options: --global_option Enable this to do fancy stuff [Flag] --help --usage -? Prints this usage information. [Flag] available commands: some_command Description of some command another_command Description of another command help Prints this usage information or bash$ myapp some_command --help usage: myapp some_command [long options...] myapp help myapp some_command --help parameters: some_parameter Some parameter that you need to supply [Required] options: --global_option Enable this to do fancy stuff [Flag] --some_option Very important option! [Int,Required] --help --usage -? Prints this usage information. [Flag] DESCRIPTION MooseX-App is a highly customisable helper to write user-friendly command line applications without having to worry about most of the annoying things usually involved. Just take any existing Moose class, add a single line ("use MooseX-App qw(PluginA PluginB ...);") and create one class for each command in an underlying namespace. Options and positional parameters can be defined as simple Moose accessors using the "option" and "parameter" keywords respectively. MooseX-App will then * Find, load and initialise the command classes (see MooseX::App::Simple for single class/command applications) * Create automated help and documentation from modules POD as well as attributes metadata and type constraints * Read, encode and validate the command line options and positional parameters entered by the user from @ARGV and %ENV (and possibly prompt the user for additional parameters see MooseX::App::Plugin::Term) * Provide helpful error messages if user input cannot be validated (either missing or wrong attributes or Moose type constraints not satisfied) or if the user requests help. Commandline options are defined using the 'option' keyword which accepts the same attributes as Moose' 'has' keyword. option 'some_option' => ( is => 'rw', isa => 'Str', ); This is equivalent to has 'some_option' => ( is => 'rw', isa => 'Str', traits => ['AppOption'], # Load extra metaclass cmd_type => 'option', # Set attribute type ); Single letter options are treated as flags and may be combined with eachother. Positional parameters are defined with the 'parameter' keyword parameter 'some_option' => ( is => 'rw', isa => 'Str', ); This is equivalent to has 'some_option' => ( is => 'rw', isa => 'Str', traits => ['AppOption'], cmd_type => 'parameter', ); All keywords are imported by Moosex::App (in the app base class) and MooseX::App::Command (in the command class) or MooseX::App::Simple (single class application). Furthermore, all options and parameters can also be supplied via %ENV option 'some_option' => ( is => 'rw', isa => 'Str', cmd_env => 'SOME_OPTION', # sets the env key ); Moose type constraints help MooseX::App to construct helpful error messages and parse @ARGV in a meaningful way. The following type constraints are supported: * ArrayRef: Specify multiple values ('--opt value1 --opt value2', also see app_permute and cmd_split) * HashRef: Specify multiple key value pairs ('--opt key=value --opt key2=value2', also see app_permute) * Enum: Display all possibilities * Bool: Flags that do not require values * Int, Num: Used for proper error messages Read the Tutorial for getting started with a simple MooseX::App command line application. METHODS new_with_command my $myapp_command = MyApp->new_with_command(); This constructor reads the command line arguments and tries to create a command class instance. If it fails it returns a MooseX::App::Message::Envelope object holding an error message. You can pass a hash of default/fallback params to new_with_command my $obj = MyApp->new_with_command(%default); Optionally you can pass a custom ARGV to this constructor my $obj = MyApp->new_with_command( ARGV => \@myARGV ); However, if you do so you must take care of propper @ARGV encoding yourself. initialize_command_class my $obj = MyApp->initialize_command_class($command_name,%default); Helper method to instantiate the command class for the given command. GLOBAL OPTIONS These options may be used to alter the default behaviour of MooseX-App. app_base app_base 'my_script'; # Defaults to $0 Usually MooseX::App will take the name of the calling wrapper script to construct the program name in various help messages. This name can be changed via the app_base function. app_fuzzy app_fuzzy 1; # default OR app_fuzzy 0; Enables fuzzy matching of commands and attributes. Is turned on by default. app_strict app_strict 0; # default OR app_strict 1; If strict is enabled the program will terminate with an error message if superfluous/unknown positional parameters are supplied. If disabled all extra parameters will be copied to the extra_argv attribute. Unknown options (with leading dashes) will always yield an error message. The command_strict config in the command classes allows one to set this option individually for each command in the respective command class. app_prefer_commandline app_prefer_commandline 0; # default or app_prefer_commandline 1; Specifies if parameters/options supplied via @ARGV,%ENV should take precedence over arguments passed directly to new_with_command. app_namespace app_namespace 'MyApp::Commands', 'YourApp::MoreCommands'; OR app_namespace(); Usually MooseX::App will take the package name of the base class as the namespace for commands. This namespace can be changed and you can add multiple extra namespaces. If app_namespace is called with no arguments then autoloading of command classes will be disabled entirely. app_exclude app_exclude 'MyApp::Commands::Roles','MyApp::Commands::Utils'; A sub namespace included via app_namespace (or the default behaviour) can be excluded using app_exclude. app_command_name app_command_name { my ($package_short,$package_full) = @_; # munge package name; return $command_name; }; This coderef can be used to control how autoloaded package names should be translated to command names. If this command returns nothing the respective command class will be skipped and not loaded. app_command_register app_command_register do => 'MyApp::Commands::DoSomething', undo => 'MyApp::Commands::UndoSomething'; This keyword can be used to register additional commands. Especially useful in conjunction with app_namespace and disabled autoloading. app_description app_description qq[Description text]; Set the app description text. If not set this information will be taken from the Pod DESCRIPTION or OVERVIEW sections. (see command_description to set usage per command) app_usage app_usage qq[myapp --option ...]; Set a custom usage text. If not set this will be taken from the Pod SYNOPSIS or USAGE section. If both sections are not available, the usage information will be autogenerated. (see command_usage to set usage per command) app_permute app_permute 0; # default OR app_permute 1; Allows one to specify multiple values with one key. So instead of writing "--list element1 --list element2 --list element3" one might write "--list element1 element2 element3" for ArrayRef elements. HashRef elements may be expressed as <--hash key=value key2=value2>. GLOBAL ATTRIBUTES All MooseX::App classes will have two extra attributes extra_argv Carries all parameters from @ARGV that were not consumed (only if app_strict is turned off, otherwise superfluous parameters will raise an exception). help_flag Help flag that is set when help was requested. ATTRIBUTE OPTIONS Options and parameters accept extra attributes for customisation: * cmd_tags - Extra tags (as used by the help) * cmd_flag - Override option/parameter name * cmd_aliases - Additional option/parameter name aliases * cmd_split - Split values into ArrayRefs on this token * cmd_position - Specify option/parameter order in help * cmd_env - Read options/parameters from %ENV * cmd_count - Value of option equals to number of occurrences in @ARGV * cmd_negate - Adds an option to negate boolean flags Refer to MooseX::App::Meta::Role::Attribute::Option for detailed documentation. METADATA MooseX::App will use your class metadata and POD to construct the commands and helpful error- or usage-messages. These bits of information are utilised and should be provided if possible: * Package names * required options for Moose attributes * documentation options for Moose attributes * Moose type constraints (Bool, ArrayRef, HashRef, Int, Num, and Enum) * Documentation set via app_description, app_usage, command_short_description, command_long_description and command_usage * POD (NAME, ABSTRACT, DESCRIPTION, USAGE, SYNOPSIS, OVERVIEW, COPYRIGHT, LICENSE, COPYRIGHT AND LICENSE, AUTHOR and AUTHORS sections) * Dzil ABSTRACT tag if no POD is available yet PLUGINS The behaviour of MooseX-App can be customised with plugins. To load a plugin just pass a list of plugin names after the "use MooseX-App" statement. (Attention: order sometimes matters) use MooseX::App qw(PluginA PluginB); Currently the following plugins are shipped with MooseX::App * MooseX::App::Plugin::BashCompletion Adds a command that generates a bash completion script for your application. See third party MooseX::App::Plugin::ZshCompletion for Z shell completion. * MooseX::App::Plugin::Color Colorful output for your MooseX::App applications. * MooseX::App::Plugin::Config Config files for MooseX::App applications. * MooseX::App::Plugin::ConfigHome Try to find config files in users home directory. * MooseX::App::Plugin::Term Prompt user for options and parameters that were not provided via options or params. Prompt offers basic editing capabilities and non-persistent history. * MooseX::App::Plugin::Typo Handle typos in command names and provide suggestions. * MooseX::App::Plugin::Version Adds a command to display the version and license of your application. * MooseX::App::Plugin::Man Display full manpage of application and commands. * MooseX::App::Plugin::MutexGroup Allow for mutally exclusive options. * MooseX::App::Plugin::Depends Adds dependent options. Refer to Writing MooseX-App Plugins for documentation on how to create your own plugins. CAVEATS & KNOWN BUGS Startup time may be an issue - escpecially if you load many plugins. If you do not require the functionality of plugins and ability for fine grained customisation (or Moose for that matter) then you should probably use MooX::Options or MooX::Cmd. In some cases - especially when using non-standard class inheritance - you may end up with command classes lacking the help attribute. In this case you need to include the following line in your base class or command classes. with qw(MooseX::App::Role::Common); When manually registering command classes (eg. via app_command_register) in multiple base classes with different sets of plugins (why would you ever want to do that?), then meta attributes may lack some attribute metaclasses. In this case you need to load the missing attribute traits explicitly: option 'argument' => ( depends => 'otherargument', trait => ['MooseX::App::Plugin::Depends::Meta::Attribute'], # load trait ); SEE ALSO Read the Tutorial for getting started with a simple MooseX::App command line application. For alternatives you can check out MooseX::App::Cmd, MooseX::Getopt, MooX::Options, MooX::Cmdand App::Cmd SUPPORT Please report any bugs or feature requests via . I will be notified, and then you'll automatically be notified of progress on your report as I make changes. AUTHOR Maroš Kollár CPAN ID: MAROS maros [at] k-1.com http://www.k-1.com CONTRIBUTORS Special thanks to all contributors. In no particular order: Andrew Jones, George Hartzell, Steve Nolte, Michael G, Thomas Klausner, Yanick Champoux, Edward Baudrez, David Golden, J.R. Mash, Thilo Fester, Gregor Herrmann, Sergey Romanov, Sawyer X, Roman F., Hunter McMillen, Maik Hentsche, Alexander Stoddard, Marc Logghe, Tina Müller, Lisa Hare You are more than welcome to contribute to MooseX-App. Please have a look at the list of open wishlist issues for ideas. COPYRIGHT MooseX::App is Copyright (c) 2012-17 Maroš Kollár. This library is free software and may be distributed under the same terms as perl itself. The full text of the licence can be found in the LICENCE file included with this module. MooseX-App-1.39/TODO000644 000765 000024 00000000123 12731304343 014346 0ustar00marosstaff000000 000000 https://github.com/maros/MooseX-App/issues?q=is%3Aissue+is%3Aopen+label%3AWhishlistMooseX-App-1.39/inc/000755 000765 000024 00000000000 13161707310 014432 5ustar00marosstaff000000 000000 MooseX-App-1.39/lib/000755 000765 000024 00000000000 13161707310 014427 5ustar00marosstaff000000 000000 MooseX-App-1.39/t/000755 000765 000024 00000000000 13161707310 014124 5ustar00marosstaff000000 000000 MooseX-App-1.39/xt/000755 000765 000024 00000000000 13161707310 014314 5ustar00marosstaff000000 000000 MooseX-App-1.39/xt/perlcritic.t000644 000765 000024 00000001015 13031675151 016641 0ustar00marosstaff000000 000000 # -*- perl -*- use strict; use warnings; use File::Spec; use Test::More; use English qw(-no_match_vars); if ( not $ENV{TEST_AUTHOR} ) { my $msg = 'Author test. Set $ENV{TEST_AUTHOR} to a true value to run.'; plan( skip_all => $msg ); } eval " use Test::Perl::Critic (-severity => 4, -exclude => ['ProhibitSubroutinePrototypes','ProhibitMultiplePackages'] ); "; if ( $EVAL_ERROR ) { my $msg = 'Test::Perl::Critic required to criticise code'; plan( skip_all => $msg ); } Test::Perl::Critic::all_critic_ok(); MooseX-App-1.39/xt/pod.t000644 000765 000024 00000000356 13031675151 015272 0ustar00marosstaff000000 000000 # -*- perl -*- use strict; use warnings; use Test::More; eval "use Test::Pod 1.14"; plan skip_all => 'Test::Pod 1.14 required' if $@; plan skip_all => 'set TEST_AUTHOR to enable this test' unless $ENV{TEST_AUTHOR}; all_pod_files_ok(); MooseX-App-1.39/xt/podcoverage.t000644 000765 000024 00000000514 13031675151 017002 0ustar00marosstaff000000 000000 # -*- perl -*- use strict; use warnings; use Test::More; eval "use Test::Pod::Coverage 1.04"; plan skip_all => 'Test::Pod::Coverage 1.04 required' if $@; plan skip_all => 'set TEST_AUTHOR to enable this test' unless $ENV{TEST_AUTHOR}; all_pod_coverage_ok({ also_private => [qw(init_meta plugin_metaroles BUILD DEMOLISH)] }); MooseX-App-1.39/xt/podstyle.t000644 000765 000024 00000001755 13031675151 016357 0ustar00marosstaff000000 000000 # -*- perl -*- use strict; use warnings; use Test::More; eval "use Pod::Simple::SimpleTree"; plan skip_all => 'Pod::Simple::SimpleTree required' if $@; eval "use Test::Pod"; plan skip_all => 'Test::Pod required' if $@; plan skip_all => 'set TEST_AUTHOR to enable this test' unless $ENV{TEST_AUTHOR}; my @files; foreach (all_pod_files()) { next if /Schema\//; next if /\.pl$/; push @files,$_; } my @required_heads=qw(NAME SYNOPSIS DESCRIPTION METHODS AUTHOR); plan tests => scalar @files * scalar @required_heads; foreach my $file (@files) { my $parser=Pod::Simple::SimpleTree->new; $parser->accept_targets('*'); my $root=$parser->parse_file($file)->root; shift(@$root);shift(@$root); my @heads; my %heads; foreach my $node (@$root) { next unless $node->[0] eq 'head1'; push(@heads,$node->[2]); $heads{$node->[2]}=1; } foreach my $heading (@required_heads) { ok($heads{$heading},"$file has $heading"); } } MooseX-App-1.39/t/00_load.t000755 000765 000024 00000006016 13025562666 015551 0ustar00marosstaff000000 000000 # -*- perl -*- # t/00_load.t - check module loading and create testing directory use Test::Most tests => 43; use_ok( 'MooseX::App' ); use_ok( 'MooseX::App::ParsedArgv' ); use_ok( 'MooseX::App::Command' ); #use_ok( 'MooseX::App::Role' ); # cannot test since it can only be loaded into a Moose::Role use_ok( 'MooseX::App::Utils' ); use_ok( 'MooseX::App::Message::Block' ); use_ok( 'MooseX::App::Message::Envelope' ); use_ok( 'MooseX::App::Meta::Role::Attribute::Option' ); use_ok( 'MooseX::App::Meta::Role::Class::Base' ); use_ok( 'MooseX::App::Meta::Role::Class::Command' ); use_ok( 'MooseX::App::Meta::Role::Class::Simple' ); use_ok( 'MooseX::App::Meta::Role::Class::Documentation'); use_ok( 'MooseX::App::Plugin::BashCompletion' ); use_ok( 'MooseX::App::Plugin::BashCompletion::Command'); use_ok( 'MooseX::App::Plugin::BashCompletion::Meta::Class'); use_ok( 'MooseX::App::Plugin::Config' ); use_ok( 'MooseX::App::Plugin::Config::Meta::Class'); use_ok( 'MooseX::App::Plugin::Version' ); use_ok( 'MooseX::App::Plugin::Version::Command'); use_ok( 'MooseX::App::Plugin::Version::Meta::Class'); use_ok( 'MooseX::App::Plugin::Man' ); use_ok( 'MooseX::App::Plugin::Man::Command'); use_ok( 'MooseX::App::Plugin::Man::Meta::Class'); use_ok( 'MooseX::App::Plugin::Depends' ); use_ok( 'MooseX::App::Plugin::Depends::Meta::Attribute'); use_ok( 'MooseX::App::Plugin::Depends::Meta::Class'); use_ok( 'MooseX::App::Plugin::MutexGroup' ); use_ok( 'MooseX::App::Plugin::MutexGroup::Meta::Attribute'); use_ok( 'MooseX::App::Plugin::MutexGroup::Meta::Class'); use_ok( 'MooseX::App::Utils'); use_ok( 'MooseX::App::Simple'); use_ok( 'MooseX::App::Exporter'); use_ok( 'MooseX::App::Role::Base'); use_ok( 'MooseX::App::Role::Common'); SKIP :{ my $ok = eval { Class::Load::load_class('Term::ReadKey'); Class::Load::load_class('IO::Interactive'); use_ok( 'MooseX::App::Plugin::Term' ); use_ok( 'MooseX::App::Plugin::Term::Meta::Class'); use_ok( 'MooseX::App::Plugin::Term::Meta::Attribute'); }; unless ($ok) { skip "Term::ReadKey and/or IO::Interactive are not installed",3; } } SKIP :{ my $ok = eval { Class::Load::load_class('Term::ANSIColor'); Class::Load::load_class('IO::Interactive'); use_ok( 'MooseX::App::Plugin::Color' ); use_ok( 'MooseX::App::Message::BlockColor' ); use_ok( 'MooseX::App::Plugin::Color::Meta::Class'); }; unless ($ok) { skip "Term::ANSIColor and/or IO::Interactive are not installed",3; } } SKIP :{ my $ok = eval { Class::Load::load_class('File::HomeDir'); use_ok( 'MooseX::App::Plugin::ConfigHome' ); use_ok( 'MooseX::App::Plugin::ConfigHome::Meta::Class'); }; unless ($ok) { skip "File::HomeDir is not installed",2; } } SKIP :{ my $ok = eval { Class::Load::load_class('Text::WagnerFischer'); use_ok( 'MooseX::App::Plugin::Typo' ); use_ok( 'MooseX::App::Plugin::Typo::Meta::Class'); }; unless ($ok) { skip "Text::WagnerFischer is not installed",2; } }MooseX-App-1.39/t/01_basic.t000755 000765 000024 00000013361 13027312717 015705 0ustar00marosstaff000000 000000 # -*- perl -*- # t/01_basic.t - Basic tests use Test::Most tests => 12+1; use Test::NoWarnings; use FindBin qw(); use lib 't/testlib'; use Test01; subtest 'Excact command with option' => sub { MooseX::App::ParsedArgv->new(argv => [qw(command_a --global 10)]); my $test01 = Test01->new_with_command(); isa_ok($test01,'Test01::CommandA'); is($test01->global,10,'Param is set'); }; subtest 'Fuzzy command with option' => sub { my $test02 = Test01->new_with_command( ARGV => [qw(Command_A --globa 11)]); isa_ok($test02,'Test01::CommandA'); is($test02->global,11,'Param is set'); }; subtest 'Wrong command' => sub { MooseX::App::ParsedArgv->new(argv => [qw(xxxx --global 10)]); my $test03 = Test01->new_with_command; isa_ok($test03,'MooseX::App::Message::Envelope'); is($test03->blocks->[0]->header,"Unknown command 'xxxx'",'Message is set'); is($test03->blocks->[0]->type,"error",'Message is of type error'); is($test03->blocks->[1]->header,"usage:",'Usage set'); is($test03->blocks->[1]->body," 01_basic.t [long options...] 01_basic.t help 01_basic.t --help",'Usage body set'); is($test03->blocks->[3]->header,"global options:",'Global options set'); is($test03->blocks->[3]->body," --global test [Required; Integer; Important!] --config Path to command config file --help -h --usage -? Prints this usage information. [Flag]",'Global options body set'); is($test03->blocks->[4]->header,"available commands:",'Available commands set'); is($test03->blocks->[4]->body," command_a Command A! command_b Test class command B for test 01 command_c1 Test C1 command_d Command A! help Prints this usage information",'Available commands body set'); }; subtest 'Help for command' => sub { MooseX::App::ParsedArgv->new(argv => [qw(command_a --help)]); my $test04 = Test01->new_with_command; isa_ok($test04,'MooseX::App::Message::Envelope'); is($test04->blocks->[0]->header,"usage:",'Usage is set'); is($test04->blocks->[0]->body," 01_basic.t command_a [long options...] 01_basic.t help 01_basic.t command_a --help",'Usage body set'); is($test04->blocks->[1]->header,"description:",'Description is set'); is($test04->blocks->[1]->body," Lorem ipsum dolor sit amet, consectetur adipiscing elit. Cras dui velit, varius nec iaculis vitae, elementum eget mi. * bullet1 * bullet2 * bullet3 Cras eget mi nisi. In hac habitasse platea dictumst.",'Description body set'); is($test04->blocks->[2]->header,"options:",'Options header is set'); is($test04->blocks->[2]->body," --global test [Required; Integer; Important!] --command_local1 some docs about the long texts that seem to occur randomly [Integer; Env: LOCAL1; Important] --command_local2 Verylongwordwithoutwhitespacestotestiftextformating worksproperly [Env: LOCAL2] --config Path to command config file --help -h --usage -? Prints this usage information. [Flag]",'Options body is set'); }; subtest 'With extra args' => sub { MooseX::App::ParsedArgv->new(argv => [qw(Command_b --global 10 --param_b aaa)]); my $test02 = Test01->new_with_command( 'param_b' => 'bbb', 'global' => 20, 'private'=>5 ); isa_ok($test02,'Test01::CommandB'); is($test02->global,20,'Param global is set'); is($test02->param_b,'bbb','Param param_b is set'); is($test02->private,5,'Param private is set'); }; subtest 'Wrapper script' => sub { my $output = `$^X $FindBin::Bin/example/test01.pl command_a --command_local2 test --global 10`; is($output,'RUN COMMAND-A:test','Output is ok'); }; subtest 'Custom help text' => sub { MooseX::App::ParsedArgv->new(argv => [qw(command_b --help)]); my $test06 = Test01->new_with_command; isa_ok($test06,'MooseX::App::Message::Envelope'); is($test06->blocks->[0]->header,"usage:",'Usage is set'); is($test06->blocks->[0]->body," use with care",'Usage is ok'); is($test06->blocks->[1]->header,"description:",'description is set'); like($test06->blocks->[1]->body,qr/ Some description of \*command B\*/,'Description is ok'); }; subtest 'Input errors missing' => sub { MooseX::App::ParsedArgv->new(argv => [qw(command_a --command_local1)]); my $test07 = Test01->new_with_command; isa_ok($test07,'MooseX::App::Message::Envelope'); is($test07->blocks->[0]->header,"Missing value for 'command_local1'",'Error message ok'); }; subtest 'Input errors type' => sub { MooseX::App::ParsedArgv->new(argv => [qw(command_a --command_local1 sss)]); my $test08 = Test01->new_with_command; isa_ok($test08,'MooseX::App::Message::Envelope'); is($test08->blocks->[0]->header,"Invalid value for 'command_local1'",'Error message ok'); is($test08->blocks->[0]->body,"Value must be an integer (not 'sss')",'Error message ok'); }; subtest 'Global help requested' => sub { MooseX::App::ParsedArgv->new(argv => [qw(help)]); my $test09 = Test01->new_with_command; isa_ok($test09,'MooseX::App::Message::Envelope'); like($test09->blocks->[0]->body,qr/ 01_basic\.t \[long options\.\.\.\]/,'Help message ok'); }; subtest 'Missing command' => sub { MooseX::App::ParsedArgv->new(argv => []); my $test10 = Test01->new_with_command; isa_ok($test10,'MooseX::App::Message::Envelope'); is($test10->blocks->[0]->header,'Missing command','Error message ok'); }; subtest 'Extra params' => sub { MooseX::App::ParsedArgv->new(argv => [qw(command_a something else)]); my $test11 = Test01->new_with_command; isa_ok($test11,'MooseX::App::Message::Envelope'); is($test11->blocks->[0]->header,"Unknown parameter 'else'",'Error message ok'); }; MooseX-App-1.39/t/02_meta.t000644 000765 000024 00000006240 13046443201 015540 0ustar00marosstaff000000 000000 # -*- perl -*- # t/02_meta.t - MOP tests use Test::Most tests => 28+1; use Test::NoWarnings; use lib 't/testlib'; use Test01; my $meta = Test01->meta; my $commands = $meta->app_commands; is(join(',',sort keys %{$commands}),'command_a,command_b,command_c1,command_d','Commands found'); is(join(',',sort values %{$commands}),'Test01::CommandA,Test01::CommandB,Test01::CommandC1,Test01::CommandD','Commands found'); cmp_deeply($meta->app_namespace,[qw(Test01)],'Command namespace ok'); is($meta->app_base,'02_meta.t','Command base ok'); is($meta->app_messageclass,'MooseX::App::Message::Block','Message class'); ok(Test01->can('new_with_command'),'Role applied to base class'); ok(Test01->can('initialize_command_class'),'Role applied to base class'); is(scalar keys %{$commands},4,'Found three commands'); is($commands->{command_a},'Test01::CommandA','Command A found'); is($meta->command_find('COMMAND_a'),'command_a','Command A matched'); cmp_deeply($meta->command_candidates('COmmand'),['command_a','command_b','command_c1','command_d'],'Command A,B,C1 and D matched'); cmp_deeply($meta->command_candidates('command_C'),['command_c1'],'Command C1 matched fuzzy'); is($meta->command_candidates('command_c1'),'command_c1','Command C1 matched exactly'); my @attributes = $meta->command_usage_attributes; is(scalar(@attributes),3,'Has three attributes'); is($attributes[0]->cmd_usage_name,'--global','Usage name ok'); is($attributes[0]->cmd_usage_description,'test [Required; Integer; Important!]','Usage description ok'); is($attributes[1]->cmd_usage_name,'--config','Usage name ok'); is($attributes[2]->cmd_usage_name,'--help -h --usage -?','Usage name ok'); is($attributes[2]->cmd_usage_description,'Prints this usage information. [Flag]','Usage description ok'); my $meta_attribute = $meta->find_attribute_by_name('global'); is(join(',',$meta_attribute->cmd_tags_list($meta_attribute)),'Required,Integer,Important!','Tags ok'); $meta_attribute->cmd_tags(['Use with care']); is(join(',',$meta_attribute->cmd_tags_list()),'Required,Integer,Use with care','Changed tags ok'); require Test01::CommandA; my $description = $meta->command_usage_description(Test01::CommandA->meta); isa_ok($description,'MooseX::App::Message::Block'); like($description->body,qr/varius nec iaculis vitae/,'Description body ok'); require Test01::CommandB; is(Test01::CommandB->meta->command_short_description,'Test class command B for test 01','Pod short description parsed ok'); is(Test01::CommandB->meta->command_long_description,'Some description of *command B* some code some code SUB HEADLINE some more desc * item 1 * item 2 * item 2.1 * item 2.2 hase ist so super and this is a very long sentence witch breaks after i have written some bla bla. another interesting paragraph.','Pod long description parsed ok'); require Test01::CommandC1; is(Test01::CommandB->meta->command_usage,'use with care','Command usage parsed ok'); is(Test01::CommandC1->meta->find_attribute_by_name('param_internal_name')->cmd_name_primary,'external_name','Attribute name ok'); is(join(',',Test01::CommandB->meta->find_attribute_by_name('param_b')->cmd_tags_list),'Required,Possible values: aaa, bbb, ccc, ddd, eee, fff','Check attributes tags');MooseX-App-1.39/t/03_utils.t000755 000765 000024 00000007561 13046443201 015765 0ustar00marosstaff000000 000000 # -*- perl -*- # t/03_utils.t use Test::Most tests => 4+1; use Test::NoWarnings; use MooseX::App::Utils; use MooseX::App::ParsedArgv; subtest 'Class to command' => sub { is(MooseX::App::Utils::class_to_command('Command'),'command','Command ok'); is(MooseX::App::Utils::class_to_command('CommandSuper'),'command_super','Command ok'); is(MooseX::App::Utils::class_to_command('CommandBA'),'command_ba','Command ok'); is(MooseX::App::Utils::class_to_command('CommandBA12'),'command_ba12','Command ok'); is(MooseX::App::Utils::class_to_command('CommandBALow'),'command_ba_low','Command ok'); }; subtest 'Format text' => sub { is( MooseX::App::Utils::format_text('Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec vitae lectus purus, quis dapibus orci. Proin mollis est in nisl congue vel ornare felis imperdiet.'), ' Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec vitae lectus purus, quis dapibus orci. Proin mollis est in nisl congue vel ornare felis imperdiet.', 'Format text ok'); is( MooseX::App::Utils::format_text('Loremipsumdolorsitamet,consecteturadipiscingelit.Namegetarcunecdolorbibendumblanditsitametnonipsum.'), ' Loremipsumdolorsitamet,consecteturadipiscingelit. Namegetarcunecdolorbibendumblanditsitametnonipsum.', 'Format text ok'); is( MooseX::App::Utils::format_text('LoremipsumdolorsitametconsecteturadipiscingelitNamegetarcunecdolorbibendumblanditsitametnonipsum.'), ' LoremipsumdolorsitametconsecteturadipiscingelitNamegetarcunecdolorbibendum blanditsitametnonipsum.', 'Format text ok'); }; subtest 'Formater' => sub { my $list = MooseX::App::Utils::format_list( ['part1','Lorem ipsum dolor sit amet, consectetur adipiscing elit. vitae lectus purus, quis dapibus orci.'], ['part2_something','Lorem ipsum dolor sit amet, consectetur adipiscing elit.'], ['part3',''], ); is( $list, ' part1 Lorem ipsum dolor sit amet, consectetur adipiscing elit. vitae lectus purus, quis dapibus orci. part2_something Lorem ipsum dolor sit amet, consectetur adipiscing elit. part3 ', 'Format list ok' ); }; subtest 'Parser' => sub { my $parser = MooseX::App::ParsedArgv->new({ argv => ['hello','--bool','mellow','-hui','--help','--help','--test','1','baer','--test','2','--xxx','x1','x2','--key=value1','--key=value2','-u','--','hase','--luchs'], hints_novalue => ['bool'], hints_permute => ['xxx'], }); is(scalar(@{$parser->elements}),13,'Has 13 elements'); is($parser->elements->[0]->key,'hello','Parameter parsed ok'); is($parser->elements->[0]->type,'parameter','Parameter type ok'); is($parser->elements->[1]->key,'bool','Flag parsed ok'); is($parser->elements->[1]->type,'option','Flag type ok'); is($parser->elements->[2]->key,'mellow','Parameter parsed ok'); is($parser->elements->[3]->key,'h','Flag parsed ok'); is($parser->elements->[4]->key,'u','Flag parsed ok'); is($parser->elements->[5]->key,'i','Flag parsed ok'); is($parser->elements->[6]->key,'help','Flag parsed ok'); is($parser->elements->[7]->key,'test','Option parsed ok'); cmp_deeply([$parser->elements->[7]->all_scalar_values],[1,2], 'Option value ok'); is($parser->elements->[8]->key,'baer','Parameter parsed ok'); is($parser->elements->[9]->key,'xxx','Parameter parsed ok'); cmp_deeply([$parser->elements->[9]->all_scalar_values],['x1','x2'],'Option value ok'); is($parser->elements->[10]->key,'key','Option parsed ok'); is($parser->elements->[10]->key,'key','Extra parsed ok'); cmp_deeply([$parser->elements->[10]->all_scalar_values],['value1','value2'],'Option value ok'); is($parser->elements->[11]->key,'hase','Extra parsed ok'); is($parser->elements->[12]->key,'--luchs','Extra parsed ok'); }; MooseX-App-1.39/t/04_plugin_config.t000644 000765 000024 00000003003 13046443201 017431 0ustar00marosstaff000000 000000 # -*- perl -*- # t/04_role_config.t - Test config role use Test::Most tests => 4+1; use Test::NoWarnings; use lib 't/testlib'; use Test01; subtest 'Command with config' => sub { MooseX::App::ParsedArgv->new(argv => [qw(command_a --config t/config.pl)]); my $test01 = Test01->new_with_command; isa_ok($test01,'Test01::CommandA'); is($test01->global,'234','Arg from command config'); is($test01->command_local1,'22','Arg from command config'); isa_ok($test01->config,'Path::Class::File'); is($test01->_config_data->{global}{global},'123','Config loaded'); }; subtest 'Another command with config' => sub { MooseX::App::ParsedArgv->new(argv => [qw(command_b --config t/config.pl --param_b bbb)]); my $test01 = Test01->new_with_command; isa_ok($test01,'Test01::CommandB'); is($test01->global,'123','Arg from command config'); }; subtest 'Command with config and argv' => sub { MooseX::App::ParsedArgv->new(argv => [qw(command_a --config t/config.pl --global 1234)]); my $test01 = Test01->new_with_command; isa_ok($test01,'Test01::CommandA'); is($test01->global,'1234','Arg from command config'); is($test01->command_local1,'22','Arg from command config'); }; subtest 'Missing config' => sub { MooseX::App::ParsedArgv->new(argv => [qw(command_a --config t/nosuchfile.pl --global 1234)]); my $test01 = Test01->new_with_command; isa_ok($test01,'MooseX::App::Message::Envelope'); like($test01->blocks->[0]->header,qr/Could not find/,'Error message set'); }; MooseX-App-1.39/t/05_extended.t000755 000765 000024 00000030100 13052066752 016421 0ustar00marosstaff000000 000000 # -*- perl -*- # t/05_extended.t - Extended tests use Test::Most tests => 29+1; use Test::NoWarnings; use FindBin qw(); use lib 't/testlib'; use Test03; Test03->meta->app_fuzzy(0); Test03->meta->app_strict(1); subtest 'Non-Fuzzy command matching' => sub { MooseX::App::ParsedArgv->new(argv => [qw(some --private 1)]); my $test01 = Test03->new_with_command; isa_ok($test01,'MooseX::App::Message::Envelope'); is($test01->blocks->[0]->header,"Unknown command 'some'","Message ok"); }; subtest 'Non-Fuzzy attribute matching' => sub { MooseX::App::ParsedArgv->new(argv => [qw(somecommand --private 1)]); my $test01 = Test03->new_with_command; isa_ok($test01,'MooseX::App::Message::Envelope'); is($test01->blocks->[0]->header,"Unknown option 'private'","Message ok"); }; Test03->meta->app_fuzzy(1); subtest 'Private option is not exposed' => sub { MooseX::App::ParsedArgv->new(argv => [qw(some --private 1)]); my $test01 = Test03->new_with_command; isa_ok($test01,'MooseX::App::Message::Envelope'); is($test01->blocks->[0]->header,"Unknown option 'private'","Message ok"); is($test01->blocks->[0]->type,"error",'Message is of type error'); }; subtest 'Options from role' => sub { MooseX::App::ParsedArgv->new(argv => [qw(some --another 10 --role 15)]); my $test02 = Test03->new_with_command; isa_ok($test02,'Test03::SomeCommand'); is($test02->another_option,'10','Param is set'); is($test02->roleattr,'15','Role param is set'); }; subtest 'Missing attribute value' => sub { MooseX::App::ParsedArgv->new(argv => [qw(some --another)]); my $test03 = Test03->new_with_command; isa_ok($test03,'MooseX::App::Message::Envelope'); is($test03->blocks->[0]->header,"Missing value for 'another'","Message ok"); is($test03->blocks->[0]->type,"error",'Message is of type error'); }; subtest 'All options available & no description' => sub { MooseX::App::ParsedArgv->new(argv => [qw(some --help)]); my $test04 = Test03->new_with_command; isa_ok($test04,'MooseX::App::Message::Envelope'); is($test04->blocks->[2]->header,'options:','No description'); is($test04->blocks->[2]->body," --global_option Enable this to do fancy stuff [Flag] --roleattr [Role] --some_option Very important option! --another [Required; Not important] --list [Multiple] --help -h --usage -? Prints this usage information. [Flag]","Message ok"); }; # Not working on cpan testers #subtest 'Test wrapper script encoding' => sub { # my $output = `LANG=en_US.UTF-8 $^X $FindBin::Bin/example/test03.pl some_command --another töst\\ möre --some_option "anöther täst"`; # is($output,'RUN:anöther täst:töst möre','Encoded output'); #} subtest 'Test type constraints integer' => sub { MooseX::App::ParsedArgv->new(argv => [qw(another --int 1a)]); my $test05 = Test03->new_with_command; isa_ok($test05,'MooseX::App::Message::Envelope'); is($test05->blocks->[0]->header,"Invalid value for 'integer'","Message ok"); }; subtest 'Test type constraints hash' => sub { MooseX::App::ParsedArgv->new(argv => [qw(another --hash xx)]); my $test06 = Test03->new_with_command; isa_ok($test06,'MooseX::App::Message::Envelope'); is($test06->blocks->[0]->header,"Invalid value for 'hash'","Message ok"); }; subtest 'Test type constraints number' => sub { MooseX::App::ParsedArgv->new(argv => [qw(another --number 2a)]); my $test07 = Test03->new_with_command; isa_ok($test07,'MooseX::App::Message::Envelope'); is($test07->blocks->[0]->header,"Invalid value for 'number'","Message ok"); }; subtest 'Test type constraints custom1' => sub { MooseX::App::ParsedArgv->new(argv => [qw(another --custom1 9)]); my $test08 = Test03->new_with_command; isa_ok($test08,'MooseX::App::Message::Envelope'); is($test08->blocks->[0]->header,"Invalid value for 'custom1'","Message ok"); }; subtest 'Test pass type constraints' => sub { MooseX::App::ParsedArgv->new(argv => [qw(another --hash key1=value1 --split a;b --split c --hash key2=value2 --integer 10 --number 10.10 --custom1 11 --custom2 test --extra1 wurtsch --count --count --cou)]); my $test09 = Test03->new_with_command; isa_ok($test09,'Test03::AnotherCommand'); is($test09->hash->{key1},"value1","Hash ok"); is($test09->hash->{key2},"value2","Hash ok"); is($test09->integer,10,"Integer ok"); is($test09->custom1,11,"Custom type 1 ok"); is(ref($test09->custom2),'SCALAR',"Custom type 2 ok"); is(${$test09->custom2},'test',"Custom type 2 ok"); is($test09->extra1,'wurtsch',"Attr set ok"); is($test09->count,3,"Count set ok"); cmp_deeply($test09->split,[qw(a b c)],'Split ok'); }; subtest 'Test ambiguous options' => sub { MooseX::App::ParsedArgv->new(argv => [qw(another --custom 1 --custom 2)]); my $test10 = Test03->new_with_command; isa_ok($test10,'MooseX::App::Message::Envelope'); is($test10->blocks->[0]->header,"Ambiguous option 'custom'","Message ok"); like($test10->blocks->[0]->body,qr/Could be custom1 custom2/,"Message ok"); }; subtest 'Test flags & defaults' => sub { MooseX::App::ParsedArgv->new(argv => [qw(yet --bool3)]); my $test11 = Test03->new_with_command; isa_ok($test11,'Test03::YetAnotherCommand'); is($test11->bool1,undef,'Bool1 flag is undef'); is($test11->bool2,1,'Bool2 flag is set'); is($test11->bool3,1,'Bool3 flag is set'); is($test11->value,'hase','Value is default'); }; subtest 'Test more flags & defaults' => sub { MooseX::App::ParsedArgv->new(argv => [qw(yet --bool3 -ab --value baer)]); my $test11 = Test03->new_with_command; isa_ok($test11,'Test03::YetAnotherCommand'); is($test11->bool1,1,'Bool1 flag is undef'); is($test11->bool2,1,'Bool2 flag is unset'); is($test11->bool3,1,'Bool3 flag is set'); is($test11->value,'baer','Value is set'); }; subtest 'Test Negate boolean options' => sub { MooseX::App::ParsedArgv->new(argv => [qw(yet --no-bool3)]); my $test11 = Test03->new_with_command; isa_ok($test11,'Test03::YetAnotherCommand'); is($test11->bool3,0,'Bool3 flag is negated'); }; subtest 'Test positional params' => sub { MooseX::App::ParsedArgv->new(argv => [qw(extra hui --value baer)]); my $test12 = Test03->new_with_command; isa_ok($test12,'Test03::ExtraCommand'); is($test12->extra1,'hui','Extra1 value is "hui"'); is($test12->extra2, undef,'Extra2 value is undef'); is($test12->alpha, undef,'alpha value is undef'); is($test12->value,'baer','Value is set'); }; subtest 'Test positional params' => sub { MooseX::App::ParsedArgv->new(argv => [qw(extra --value baer hui)]); my $test12 = Test03->new_with_command; isa_ok($test12,'Test03::ExtraCommand'); is($test12->extra1,'hui','Extra1 value is "hui"'); is($test12->extra2, undef,'Extra2 value is undef'); is($test12->alpha, undef,'alpha value is undef'); is($test12->value,'baer','Value is set'); }; subtest 'Test optional positional params' => sub { MooseX::App::ParsedArgv->new(argv => [qw(extra hui 11 --value baer)]); my $test12 = Test03->new_with_command; isa_ok($test12,'Test03::ExtraCommand'); is($test12->extra1,'hui','Extra1 value is "hui"'); is($test12->extra2,11,'Extra2 value is "11"'); is($test12->alpha, undef,'alpha value is undef'); is($test12->value,'baer','Value is set'); }; subtest 'Test wrong positional params' => sub { MooseX::App::ParsedArgv->new(argv => [qw(extra hui aa --value baer)]); my $test13 = Test03->new_with_command; isa_ok($test13,'MooseX::App::Message::Envelope'); is($test13->blocks->[0]->header,"Invalid value for 'extra2'","Error message ok"); is($test13->blocks->[2]->header,"parameters:","Usage header ok"); is($test13->blocks->[2]->body," extra1 Important extra parameter [Required] extra2 [Integer] alpha [Integer]","Usage body ok"); }; subtest 'Test missing positional params' => sub { MooseX::App::ParsedArgv->new(argv => [qw(extra --value baer)]); my $test14 = Test03->new_with_command; isa_ok($test14,'MooseX::App::Message::Envelope'); is($test14->blocks->[0]->header,"Required parameter 'extra1' missing","Message ok"); }; Test03->meta->app_fuzzy(1); Test03->meta->app_strict(0); subtest 'Test extra positional params' => sub { MooseX::App::ParsedArgv->new(argv => [qw(extra p1 22 33 marder dachs --value 44 --flag luchs --flagg fuchs -- baer --hase)]); my $test15 = Test03->new_with_command; isa_ok($test15,'Test03::ExtraCommand'); is($test15->extra1,'p1','Param 1 ok'); is($test15->extra2,'22','Param 2 ok'); is($test15->alpha,'33','Param 3 ok'); cmp_deeply($test15->extra_argv,[qw(marder dachs luchs fuchs baer --hase)],'Uncomsumed option ok'); }; subtest 'Test parameter preference' => sub { MooseX::App::ParsedArgv->new(argv => [qw(extra extra1 22 --value 13 --flag)]); my $test16 = Test03->new_with_command(extra1 => 'extra1man', value => 14, flag => 0, flaggo => 1); isa_ok($test16,'Test03::ExtraCommand'); is($test16->extra1,"extra1man","Extra param from new_with_command ok"); is($test16->extra2,22,"Extra param from argv ok"); is($test16->value,14,"value option from argv ok"); is($test16->flag,0,"Flag from new_with_command ok"); is($test16->flaggo,1,"Flago from new_with_command ok"); }; Test03->meta->app_prefer_commandline(1); subtest 'Test parameter preference reverse' => sub { MooseX::App::ParsedArgv->new(argv => [qw(extra extra1 22 --value 13 --flag)]); my $test17 = Test03->new_with_command(extra1 => 'extra1man', value => 14, flag => 0, flaggo => 1); isa_ok($test17,'Test03::ExtraCommand'); is($test17->extra1,"extra1","Extra param from new_with_command ok"); is($test17->extra2,22,"Extra param from argv ok"); is($test17->value,13,"value option from argv ok"); is($test17->flag,1,"Flag from new_with_command ok"); is($test17->flaggo,1,"Flago from new_with_command ok"); }; subtest 'Test enum error message' => sub { MooseX::App::ParsedArgv->new(argv => [qw(somecommand --another hase hh h ggg)]); my $test18 = Test03->new_with_command(); isa_ok($test18,'MooseX::App::Message::Envelope'); is($test18->blocks->[0]->body,"Value must be one of these values: aaa, bbb, ccc, ddd, eee, fff (not 'ggg')","Check enum error message"); }; subtest 'Test empty multi' => sub { MooseX::App::ParsedArgv->new(argv => [qw(somecommand --another hase --list val1 --list val2 --list)]); my $test19 = Test03->new_with_command(); isa_ok($test19,'Test03::SomeCommand'); is(scalar(@{$test19->list}),3,'Has three list items'); is($test19->list->[0],'val1','First value ok'); is($test19->list->[1],'val2','Second value ok'); is($test19->list->[2],undef,'First value empty'); }; subtest 'Test permute' => sub { MooseX::App::ParsedArgv->new(argv => [qw(differentcommand --list elem1 elem2 --list elem3 --int 10 --hash key1=val1 key2=val2)]); my $test20 = Test03->new_with_command(); cmp_deeply($test20->list,[qw(elem1 elem2 elem3)],'Permute array ok'); cmp_deeply($test20->hash,{ key1 => 'val1', key2 => 'val2' },'Permute hash ok'); }; subtest 'Test permute off' => sub { Test03->meta->app_permute(0); MooseX::App::ParsedArgv->new(argv => [qw(differentcommand --list elem1 elem2 --list elem3 --int 10 --hash key1=val1 key2=val2)]); my $test20 = Test03->new_with_command(); cmp_deeply($test20->list,[qw(elem1 elem3)],'No permute array ok'); cmp_deeply($test20->hash,{ key1 => 'val1' },'No permute hash ok'); Test03->meta->app_permute(1); }; subtest 'Test parameter order' => sub { MooseX::App::ParsedArgv->new(argv => [qw(somecommand cc1 --another dd aa1 bbb)]); my $test21 = Test03->new_with_command(); is($test21->param_a,'aa1','Param a ok'); is($test21->param_b,'bbb','Param b ok'); is($test21->param_c,'cc1','Param c ok'); }; subtest 'Test mixed multi' => sub { my $x = MooseX::App::ParsedArgv->new(argv => [qw(somecommand --another hase --li val1 --lis val2 --list val3 --lis val4)]); my $test22 = Test03->new_with_command(); isa_ok($test22,'Test03::SomeCommand'); cmp_deeply($test22->list,[qw(val1 val2 val3 val4)],'List ok'); };MooseX-App-1.39/t/06_env.t000644 000765 000024 00000003170 13046443201 015405 0ustar00marosstaff000000 000000 # -*- perl -*- # t/06_plugin_env.t - Test env use Test::Most tests => 5+1; use Test::NoWarnings; use lib 't/testlib'; use Test01; subtest 'Command with argv' => sub { MooseX::App::ParsedArgv->new(argv => [qw(command_a --command_local1 11 --global 1)]); my $test01 = Test01->new_with_command; isa_ok($test01,'Test01::CommandA'); is($test01->command_local1,'11','Arg from command config'); }; subtest 'Command only with env' => sub { MooseX::App::ParsedArgv->new(argv => [qw(command_a --global 1)]); local $ENV{LOCAL1} = 12; my $test01 = Test01->new_with_command; isa_ok($test01,'Test01::CommandA'); is($test01->command_local1,'12','Arg from command env'); }; subtest 'Command with env and argv' => sub { MooseX::App::ParsedArgv->new(argv => [qw(command_a --command_local1 13 --global 1)]); local $ENV{LOCAL1} = 12; my $test01 = Test01->new_with_command; isa_ok($test01,'Test01::CommandA'); is($test01->command_local1,'13','Arg from command argv'); }; subtest 'Env not passing type constraint' => sub { MooseX::App::ParsedArgv->new(argv => [qw(command_a --global 1)]); local $ENV{LOCAL1} = 'aa'; my $test01 = Test01->new_with_command; isa_ok($test01,'MooseX::App::Message::Envelope'); is($test01->blocks->[0]->header,"Invalid environment value for 'LOCAL1'","Message ok"); }; subtest 'Coerce env value' => sub { MooseX::App::ParsedArgv->new(argv => [qw(command_d --global 1)]); local $ENV{LOCAL1} = 42; my $test01 = Test01->new_with_command; isa_ok($test01,'Test01::CommandD'); is_deeply($test01->command_local1,[42],'Arg coerced from command env'); };MooseX-App-1.39/t/07_single.t000644 000765 000024 00000002010 13046443201 016067 0ustar00marosstaff000000 000000 # -*- perl -*- # t/07_single.t- Test MooseX::App::Single use Test::Most tests => 3+1; use Test::NoWarnings; use lib 't/testlib'; use Test05; subtest 'Single command' => sub { MooseX::App::ParsedArgv->new(argv => [qw()]); my $test05 = Test05->new_with_options; isa_ok($test05,'MooseX::App::Message::Envelope'); is($test05->blocks->[0]->header,"Required option 'another_option' missing","Check for error message"); }; subtest 'Single command' => sub { MooseX::App::ParsedArgv->new(argv => [qw(--another_option 123)]); my $test05 = Test05->new_with_options({ some_option => 1 }); isa_ok($test05,'Test05'); is($test05->another_option,'123','Arg from command ARGV'); is($test05->some_option,1,'Arg from new_with_options'); }; subtest 'Single command help' => sub { MooseX::App::ParsedArgv->new(argv => [qw(--help)]); my $test05 = Test05->new_with_options(); isa_ok($test05,'MooseX::App::Message::Envelope'); is($test05->blocks->[0]->header,"usage:","Usage header is first"); }; MooseX-App-1.39/t/08_plugin_various.t000644 000765 000024 00000002235 13004440116 017662 0ustar00marosstaff000000 000000 # -*- perl -*- # t/08_plugin_various.t - Test various plugin use strict; use Test::Most tests => 2+1; use Test::NoWarnings; use lib 't/testlib'; use Test03; subtest 'Bash completion' => sub { MooseX::App::ParsedArgv->new(argv => [qw(bash_completion)]); my $test01 = Test03->new_with_command; isa_ok($test01,'MooseX::App::Message::Envelope'); my $bash_completion = $test01->stringify; like($bash_completion,qr/_test03_macc_somecommand\(\)\s\{/,'some_command present'); like($bash_completion,qr/--global_option/,'global_option present'); like($bash_completion,qr/--roleattr/,'roleattr present'); unlike($bash_completion,qr/bash_completion/,'bash_completion is not included'); }; subtest 'Version' => sub { MooseX::App::ParsedArgv->new(argv => [qw(version)]); my $test02 = Test03->new_with_command; isa_ok($test02,'MooseX::App::Message::Envelope'); my $version = $test02->stringify; like($version,qr/\s*test03\s+version\s+22\.02/s,'Check for app version'); like($version,qr/\s*MooseX::App\sversion\s\d+\.\d+/s,'Check for MooseX::App version'); like($version,qr/This library is free software/s,'License included'); }; MooseX-App-1.39/t/09_classes.t000644 000765 000024 00000005027 13046443201 016260 0ustar00marosstaff000000 000000 # -*- perl -*- # t/09_classes.t - Test classes use Test::Most tests => 6+1; use Test::NoWarnings; use lib 't/testlib'; use Test04; use Test03; subtest 'Extend base class' => sub { MooseX::App::ParsedArgv->new(argv => [qw()]); my $test01 = Test04->new_with_command; isa_ok($test01,'MooseX::App::Message::Envelope'); like($test01->blocks->[2]->body,qr/--test1\s+\[Integer\]/,'--test1 included'); like($test01->blocks->[2]->body,qr/--test2\s+\[Flag\]/,'--test2 included'); unlike($test01->blocks->[2]->body,qr/--test3/,'--test3 not included'); }; subtest 'Wrong usage' => sub { throws_ok { Test03->new->new_with_command } qr/new_with_command is a class method/, 'Only callable as class method'; use Test03::SomeCommand; throws_ok { Test03::SomeCommand->new_with_command } qr/new_with_command may only be called from the application base package/, 'new_with_command may only be called from the application base package'; throws_ok { Test03->new_with_command(1,2,3) } qr/new_with_command got invalid extra arguments/, 'Wrong default args'; }; subtest 'Conflicts' => sub { MooseX::App::ParsedArgv->new(argv => [qw(broken --conflict a)]); throws_ok { Test03->new_with_command; } qr/Command line option conflict/, 'Conflict detected'; }; subtest 'Default args available with extra inheritance' => sub { MooseX::App::ParsedArgv->new(argv => [qw(yetanothercommand --help)]); my $another = Test03->new_with_command; isa_ok($another,'MooseX::App::Message::Envelope'); like($another->blocks->[0]->body,qr/test03\syetanothercommand/,'Help ok'); is($another->blocks->[0]->header,'usage:','Help ok'); MooseX::App::ParsedArgv->new(argv => [qw(yetanothercommand -ab --bool3)]); my $yetanother = Test03->new_with_command(private => 'test'); isa_ok($yetanother,'Test03::YetAnotherCommand'); is($yetanother->private,'test','Option has been passed on'); }; subtest 'Attributes from role' => sub { MooseX::App::ParsedArgv->new(argv => [qw(somecommand --roleattr a --another b)]); my $test03 = Test03->new_with_command(); isa_ok($test03,'Test03::SomeCommand'); is($test03->roleattr,'a','Attribute from role ok'); }; subtest 'Correct order from role ' => sub { MooseX::App::ParsedArgv->new(argv => [qw(somecommand a1 b2 ccc --another b)]); my $test03 = Test03->new_with_command; isa_ok($test03,'Test03::SomeCommand'); is($test03->param_c,'a1','First from role'); is($test03->param_a,'b2','Second from role'); is($test03->param_b,'ccc','Third from role'); }; MooseX-App-1.39/t/10_plugin_mutexgroup.t000644 000765 000024 00000002536 13046443201 020412 0ustar00marosstaff000000 000000 # -*- perl -*- # t/10_plugin_mutexgroup.t - Test MutexGroup use Test::Most tests => 1+1; use Test::NoWarnings; use lib 't/testlib'; use Test07; subtest 'MutexGroup' => sub { plan tests => 7; { my $test01 = Test07->new_with_options( UseAmmonia => 1, UseChlorine => 1 ); isa_ok( $test01, 'MooseX::App::Message::Envelope' ); my @errors = grep { $_->type eq 'error' } @{ $test01->blocks }; is( scalar @errors, 1, 'only returned a single error' ); is( $errors[0]->header, 'Options UseAmmonia and UseChlorine are mutally exclusive', 'generated an error when more than one option in the same mutexgroup is initialized' ); } { my $test02 = Test07->new_with_options(); isa_ok( $test02, 'MooseX::App::Message::Envelope' ); my @errors = grep { $_->type eq 'error' } @{ $test02->blocks }; is( scalar @errors, 1, 'only returned a single error' ); is( $errors[0]->header, 'Either UseAmmonia or UseChlorine must be specified', 'generated an error when no options in the same mutexgroup are initialized' ); } { my $test03 = Test07->new_with_options( UseAmmonia => 1 ); ok( $test03->isa('Test07'), 'generated no errors when only a single option from the same mutexgroup is initialized' ); } }; MooseX-App-1.39/t/11_process.t000644 000765 000024 00000005267 13037503110 016274 0ustar00marosstaff000000 000000 # -*- perl -*- # t/11_process.t - Test via subprocesses use Test::Most tests => 1+1; use Test::NoWarnings; use FindBin qw(); use IPC::Open3 qw(open3); use Symbol qw(gensym); my $BASE = "$^X $FindBin::Bin/example"; subtest 'Test basic exit codes' => sub { SKIP: { skip "Cannot test on MSWin",7 if $^O =~ /^MSWin/; test_subprocess( bin => 'test02.pl', exit => 127, out => '', err => qr/Missing command/, ); test_subprocess( bin => 'test02.pl error', exit => 25, err => qr/XXX/, ); test_subprocess( bin => 'test02.pl version', exit => 0, out => qr/VERSION/, err => '', ); test_subprocess( bin => 'test02.pl version', exit => 0, out => qr/VERSION/, err => '', ); test_subprocess( bin => 'test02.pl record --help', exit => 0, out => qr/usage:/, err => '', ); test_subprocess( bin => 'test02.pl record', exit => 0, out => qr/RAN/, err => '', ); test_subprocess( bin => 'test02.pl record --notthere', exit => 1, out => '', err => qr/Unknown option 'notthere'/, ); } }; sub test_subprocess { my (%params) = @_; $params{args} ||= []; my($in_fh, $out_fh, $err_fh, $out, $err, $pid, $exit); $err_fh = gensym; eval { $pid = open3( $in_fh, $out_fh, $err_fh, $BASE.'/'.$params{bin}, ); }; if ($@) { fail('Error running '.$params{bin}.' :'.$@); return; } if (defined $pid) { waitpid($pid,0); $exit = $? >> 8; $out = ''; while(<$out_fh>) { $out .= $_; } $err = ''; while(<$err_fh>) { $err .= $_; } } if (exists $params{exit}) { is($exit,$params{exit},'Exitcode '.$params{bin}.' ok'); } if (exists $params{out}) { if (ref $params{out} eq 'Regexp') { like($out,$params{out},'Output '.$params{bin}.' ok'); } else { is($out,$params{out},'Output '.$params{bin}.' ok'); } } if (exists $params{err}) { if (ref $params{err} eq 'Regexp') { like($err,$params{err},'Error '.$params{bin}.' ok'); } else { is($err,$params{err},'Error '.$params{bin}.' ok'); } } return; }MooseX-App-1.39/t/12_plugin_depends.t000644 000765 000024 00000003120 13046443201 017605 0ustar00marosstaff000000 000000 # -*- perl -*- # t/12_plugin_depends.t - Test Depends use Test::Most tests => 1+1; use Test::NoWarnings; use lib 't/testlib'; use Test08; subtest 'Depends' => sub { plan tests => 8; { my $test01 = Test08->new_with_options( WriteToFile => 1 ); isa_ok( $test01, 'MooseX::App::Message::Envelope' ); my @errors = grep { $_->type eq 'error' } @{ $test01->blocks }; is( scalar @errors, 1, 'only returned a single error' ); is( $errors[0]->header, 'Option \'WriteToFile\' requires \'FileFormat\' to be defined', 'generated an error when an option dependency was not present' ); } { my $test02 = Test08->new_with_options( ReadFromFile => 1 ); isa_ok( $test02, 'MooseX::App::Message::Envelope' ); my @errors = grep { $_->type eq 'error' } @{ $test02->blocks }; is( scalar @errors, 1, 'only returned a single error' ); is( $errors[0]->header, 'Option \'ReadFromFile\' requires \'FileFormat\' to be defined', 'generated an error when an option dependency was not present' ); } { my $test03 = Test08->new_with_options( WriteToFile => 1, FileFormat => 'tsv' ); ok( ! $test03->can('blocks'), 'generated no errors when both an option and its dependencies are defined' ); } { my $test04 = Test08->new_with_options( ReadFromFile => 1, FileFormat => 'tsv' ); ok( ! $test04->can('blocks'), 'generated no errors when both an option and its dependencies are defined' ); } }; MooseX-App-1.39/t/13_rt_112156.t000644 000765 000024 00000004576 13025562666 016110 0ustar00marosstaff000000 000000 # -*- perl -*- # t/13_rt_112156.t - RT112156 inheritance use Test::Most tests => 2+1; use Test::NoWarnings; use lib 't/testlib'; { package Test13; use MooseX::App qw(Depends); option 'unrelated' => ( is => 'rw', isa => 'Int', documentation => 'One thing', ); } { package Test13::SomeCommand; use MooseX::App::Command; # no inheritance option 'one' => ( is => 'rw', isa => 'Int', documentation => 'One thing', depends => ['other'], ); option 'other' => ( is => 'rw', isa => 'Int', documentation => 'Other thing', ); sub run { my ($self) = @_; return "ok"; } } { package Test13::AnotherCommand; use MooseX::App::Command; extends qw(Test13); option 'one' => ( is => 'rw', isa => 'Int', documentation => 'One thing', depends => ['other'], ); option 'other' => ( is => 'rw', isa => 'Int', documentation => 'Other thing', ); sub run { my ($self) = @_; return "ok"; } } subtest 'no inheritance' => sub { plan tests => 8; { MooseX::App::ParsedArgv->new(argv => [qw(some --one 1 --other 2)]); my $test01 = Test13->new_with_command(); isa_ok($test01,'Test13::SomeCommand'); is($test01->one,1,'Option ok'); is($test01->other,2,'Option ok'); ok(! $test01->can('unrelated'),'No option'); } { MooseX::App::ParsedArgv->new(argv => [qw(another --one 1 --other 2 --unrelated 3)]); my $test02 = Test13->new_with_command(); isa_ok($test02,'Test13::AnotherCommand'); is($test02->one,1,'Option ok'); is($test02->other,2,'Option ok'); is($test02->unrelated,3,'Option ok'); } }; subtest 'check plugin functionality' => sub { plan tests => 2; { MooseX::App::ParsedArgv->new(argv => [qw(some --one 1)]); my $test03 = Test13->new_with_command(); isa_ok( $test03, 'MooseX::App::Message::Envelope' ); } { MooseX::App::ParsedArgv->new(argv => [qw(another --one 1)]); my $test03 = Test13->new_with_command(); isa_ok( $test03, 'MooseX::App::Message::Envelope' ); } }; MooseX-App-1.39/t/14_gh_45.t000644 000765 000024 00000003412 13025562666 015537 0ustar00marosstaff000000 000000 # -*- perl -*- # t/14_gh_45.t - Boolean negation use Test::Most tests => 3+1; use Test::NoWarnings; use lib 't/testlib'; { package Test14; use MooseX::App::Simple; option 'b1' => ( is => 'rw', isa => 'Bool', cmd_negate => ['not-b1'] ); option 'not_b1' => ( is => 'rw', isa => 'Bool', ); option 'b2yes' => ( is => 'rw', isa => 'Bool', cmd_negate => ['no_b2','unb2'] ); sub run { my ($self) = @_; return "ok"; } } subtest 'boolean negation' => sub { plan tests => 4; Test14->meta->app_fuzzy(0); { MooseX::App::ParsedArgv->new(argv => [qw(--not-b1 --not_b1 --b2yes)]); my $test01 = Test14->new_with_options(); isa_ok($test01,'Test14'); is($test01->b1,0,'Did not set b1'); is($test01->not_b1,1,'Did set not_b1'); is($test01->b2yes,1,'Did set b2'); } }; subtest 'boolean fuzzy negation' => sub { plan tests => 4; Test14->meta->app_fuzzy(1); { MooseX::App::ParsedArgv->new(argv => [qw(--not-b --not_b --b2)]); my $test01 = Test14->new_with_options(); isa_ok($test01,'Test14'); is($test01->b1,0,'Did not set b1'); is($test01->not_b1,1,'Did set not_b1'); is($test01->b2yes,1,'Did set b2'); } }; subtest 'ambiguous negation' => sub { plan tests => 3; Test14->meta->app_fuzzy(1); { MooseX::App::ParsedArgv->new(argv => [qw(--not-b1 --b1 --b2yes --no_b2 --unb2 --b2 --un)]); my $test01 = Test14->new_with_options(); isa_ok($test01,'Test14'); is($test01->b1,1,'Did set b1'); is($test01->b2yes,0,'Did not set b2'); } };MooseX-App-1.39/t/15_subcommands.t000644 000765 000024 00000003364 13161706671 017150 0ustar00marosstaff000000 000000 # -*- perl -*- # t/15_subcommands.t use strict; use warnings; use Test::More tests => 3+1; use Test::NoWarnings; use lib 't/testlib'; { package Test15; use MooseX::App; } { package Test15::Foo; use MooseX::App::Command; sub run { "running foo" } command_short_description "Toplevel command"; } { package Test15::Foo::Bar; use MooseX::App::Command; sub run { "running bar" } command_short_description "Bar subcommand"; } { package Test15::Foo::Baz; use MooseX::App::Command; sub run { "running baz" } command_short_description "Baz subcommand"; } subtest 'Basic Subcommands' => sub { isa_ok(Test15->new_with_command( ARGV => [ 'foo' ] ),'Test15::Foo'); isa_ok(Test15->new_with_command( ARGV => [ 'foo','bar' ] ),'Test15::Foo::Bar'); isa_ok(Test15->new_with_command( ARGV => [ 'foo','baz' ] ),'Test15::Foo::Baz'); isa_ok(Test15->new_with_command( ARGV => [ 'foo','qux' ] ),'Test15::Foo'); }; subtest 'Help Subcommand' => sub { my $help = Test15->new_with_command( ARGV => [ 'help' ] ); isa_ok($help,'MooseX::App::Message::Envelope'); is($help->blocks->[2]->header,'available commands:','Command headline set'); is($help->blocks->[2]->body," foo Toplevel command foo bar Bar subcommand foo baz Baz subcommand help Prints this usage information",'Command body set'); }; subtest 'Help Parent' => sub { my $help = Test15->new_with_command( ARGV => [ 'foo','--help' ] ); isa_ok($help,'MooseX::App::Message::Envelope'); is($help->blocks->[3]->header,'available subcommands:','Command headline set'); is($help->blocks->[3]->body," bar Bar subcommand baz Baz subcommand help Prints this usage information",'Command body set'); };MooseX-App-1.39/t/16_rt122946.t000644 000765 000024 00000001272 13161707224 015742 0ustar00marosstaff000000 000000 # -*- perl -*- # t/16_rt122946.t use strict; use warnings; use Test::More tests => 1+1; use Test::NoWarnings; use Test::Exception; use lib 't/testlib'; { package Test16; use MooseX::App::Simple; option 'parama' => ( is => 'rw', isa => 'Int', cmd_aliases => ['a'] ); option 'paramb' => ( is => 'rw', isa => 'Bool', cmd_aliases => ['b'] ); option 'paramab' => ( is => 'rw', isa => 'Int', cmd_aliases => ['ab'] ); } subtest 'Option flags' => sub { throws_ok { Test16->new_with_options( ARGV => [ '-ab' ] ) } qr/Option param[ab] has a single letter flag but no Bool/; }; MooseX-App-1.39/t/config.pl000644 000765 000024 00000000232 11762214012 015720 0ustar00marosstaff000000 000000 { global => { global => 123, }, command_a => { global => 234, command_local1 => 22, }, }MooseX-App-1.39/t/example/000755 000765 000024 00000000000 13161707310 015557 5ustar00marosstaff000000 000000 MooseX-App-1.39/t/testlib/000755 000765 000024 00000000000 13161707310 015572 5ustar00marosstaff000000 000000 MooseX-App-1.39/t/testlib/Test01/000755 000765 000024 00000000000 13161707310 016652 5ustar00marosstaff000000 000000 MooseX-App-1.39/t/testlib/Test01.pm000644 000765 000024 00000000613 12546021244 017211 0ustar00marosstaff000000 000000 package Test01; use Moose; use MooseX::App qw(Config); app_strict 1; app_prefer_commandline 0; app_description "Huissasa"; option 'global' => ( isa => 'Int', is => 'rw', required => 1, documentation => q[test], cmd_tags => ['Important!'], ); has 'private' => ( isa => 'Int', is => 'rw', ); 1; MooseX-App-1.39/t/testlib/Test02/000755 000765 000024 00000000000 13161707310 016653 5ustar00marosstaff000000 000000 MooseX-App-1.39/t/testlib/Test02.pm000644 000765 000024 00000000706 13025562666 017230 0ustar00marosstaff000000 000000 package Test02; use Moose; use MooseX::App (qw(BashCompletion Version Man), ($ENV{HARNESS_ACTIVE} ? ():qw(ConfigHome Color Typo Term) )); our $VERSION = 1.01; app_namespace "Test02::Command","Test02::MoreCommands"; #app_fuzzy; sub run { print "RAN"; } 1; =encoding utf8 =head1 NAME Test02 - Test 02 =head1 SYNOPSIS do something =head1 LICENSE This library is free software and may be distributed under the same terms as perl itself. =cutMooseX-App-1.39/t/testlib/Test03/000755 000765 000024 00000000000 13161707310 016654 5ustar00marosstaff000000 000000 MooseX-App-1.39/t/testlib/Test03.pm000644 000765 000024 00000001151 13110107052 017177 0ustar00marosstaff000000 000000 package Test03; use MooseX::App qw(BashCompletion Version); our $VERSION = '22.02'; app_permute 1; app_base 'test03'; app_command_name { my ($package) = @_; return lc($package); }; app_exclude qw(Test03::Role); option 'global_option' => ( is => 'rw', isa => 'Bool', #default => 0, #required => 1, documentation => q[Enable this to do fancy stuff], ); has 'hidden_option' => ( is => 'rw', ); sub run { print "RAN"; } 1; =head1 LICENSE This library is free software and may be distributed under the same terms as perl itself. =cutMooseX-App-1.39/t/testlib/Test03CommandBase.pm000644 000765 000024 00000000541 12454262644 021316 0ustar00marosstaff000000 000000 # ============================================================================ package Test03CommandBase; # ============================================================================ use utf8; use namespace::autoclean; use Moose; has 'private' => ( is => 'rw', isa => 'Str', ); __PACKAGE__->meta->make_immutable; 1;MooseX-App-1.39/t/testlib/Test04.pm000644 000765 000024 00000000264 12123556074 017223 0ustar00marosstaff000000 000000 package Test04; #use Moose; use MooseX::App; extends qw(Test04Base); option 'test1' => ( is => 'rw', isa => 'Int', ); option '+test2' => (); 1;MooseX-App-1.39/t/testlib/Test04Base.pm000644 000765 000024 00000000462 13025562666 020024 0ustar00marosstaff000000 000000 package Test04Base; use Moose; has 'test1' => ( is => 'rw', isa => 'Str', ); has 'test2' => ( is => 'rw', isa => 'Bool', ); has 'test3' => ( is => 'rw', isa => 'Str', ); sub run { print "RAN"; } 1;MooseX-App-1.39/t/testlib/Test05.pm000644 000765 000024 00000001034 13025562666 017226 0ustar00marosstaff000000 000000 package Test05; #use Moose; use MooseX::App::Simple qw(Config); app_fuzzy 1; option 'some_option' => ( is => 'rw', isa => 'Bool', documentation => q[Enable this to do fancy stuff], ); option 'another_option' => ( is => 'rw', isa => 'Str', documentation => q[Enable this to do fancy stuff], required => 1, cmd_env => 'ANOTHER', ); sub run { my ($self) = @_; warn $self->dump; } 1; =head1 DESCRIPTION this is how we use this command =cut MooseX-App-1.39/t/testlib/Test06/000755 000765 000024 00000000000 13161707310 016657 5ustar00marosstaff000000 000000 MooseX-App-1.39/t/testlib/Test06.pm000644 000765 000024 00000000674 12520617604 017230 0ustar00marosstaff000000 000000 package Test06; use MooseX::App qw(Config); app_fuzzy(1); #app_namespace(); app_command_name { my @parts = split( /[_\s]+|\b|(? 'Test03::ExtraCommand'; app_permute 1; option 'some_option' => ( is => 'rw', isa => 'Bool', documentation => q[Enable this to do fancy stuff], ); 1;MooseX-App-1.39/t/testlib/Test07.pm000644 000765 000024 00000000653 12520455702 017225 0ustar00marosstaff000000 000000 package Test07; use MooseX::App::Simple qw(MutexGroup); option 'UseAmmonia' => ( is => 'ro', isa => 'Bool', mutexgroup => 'NonMixableCleaningChemicals', ); option 'UseChlorine' => ( is => 'ro', isa => 'Bool', mutexgroup => 'NonMixableCleaningChemicals' ); has 'private_option' => ( is => 'ro', isa => 'Int', default => 0, ); sub run { print "ok"; } 1; MooseX-App-1.39/t/testlib/Test08.pm000644 000765 000024 00000001047 12520455702 017224 0ustar00marosstaff000000 000000 package Test08; use MooseX::App::Simple qw(MutexGroup Depends); use Moose::Util::TypeConstraints; option 'FileFormat' => ( is => 'ro', isa => enum([qw(csv tsv xml)]), ); option 'WriteToFile' => ( is => 'ro', isa => 'Bool', mutexgroup => 'FileOp', depends => [qw(FileFormat)], ); option 'ReadFromFile' => ( is => 'ro', isa => 'Bool', mutexgroup => 'FileOp', depends => [qw(FileFormat)], ); has 'private_option' => ( is => 'ro', isa => 'Int', default => 0, ); 1; MooseX-App-1.39/t/testlib/Test06/CommandA.pm000644 000765 000024 00000001260 13025562666 020707 0ustar00marosstaff000000 000000 package Test06::CommandA; use Moose; use MooseX::App::Command; extends qw(Test06); use Moose::Util::TypeConstraints; subtype 'Test06::local2' => as 'Str' => where { $_ =~ /^[aA]/ }; #=> message { "Must start with an 'A'" }; no Moose::Util::TypeConstraints; option 'command_local2' => ( isa => 'Test06::local2', is => 'rw', documentation => q[Verylongwordwithoutwhitespacestotestiftextformatingworksproperly], cmd_env => 'LOCAL2', ); sub run { my ($self) = @_; print "NEW WITH A"; ref($self)->initialize_command_class('Test06::CommandB')->run; #$self->initialize_command_class('Test06::CommandB'); } 1;MooseX-App-1.39/t/testlib/Test06/CommandB.pm000644 000765 000024 00000000322 13025562666 020706 0ustar00marosstaff000000 000000 package Test06::CommandB; use Moose; #use MooseX::App::Command; extends qw(Test06); has 'email' => ( isa => 'Str', is => 'rw', ); sub run { my ($self) = @_; warn $self; } 1;MooseX-App-1.39/t/testlib/Test06/CommandD.pm000644 000765 000024 00000000643 12520617604 020706 0ustar00marosstaff000000 000000 package Test06::CommandD; use Moose; use MooseX::App::Command; extends qw(Test06); option 'list' => ( isa => 'ArrayRef[Str]', is => 'rw', ); option 'hash' => ( isa => 'HashRef[Str]', is => 'rw', ); sub run { my ($self) = @_; use Data::Dumper; { local $Data::Dumper::Maxdepth = 2; warn __FILE__.':line'.__LINE__.':'.Dumper($self); } } 1;MooseX-App-1.39/t/testlib/Test03/AnotherCommand.pm000644 000765 000024 00000002177 12465625113 022126 0ustar00marosstaff000000 000000 package Test03::AnotherCommand; use MooseX::App::Command; extends qw(Test03CommandBase); use Moose::Util::TypeConstraints; subtype 'Test03::Type::Custom1', as 'Int', where { $_ > 10 }, message { "Must be greater than 10" }; subtype 'Test03::Type::Custom2', as 'ScalarRef'; coerce 'Test03::Type::Custom2', from 'Str', via { \$_ }; no Moose::Util::TypeConstraints; option 'hash' => ( is => 'rw', isa => 'HashRef', ); option 'integer' => ( is => 'rw', isa => 'Int', ); option 'number' => ( is => 'rw', isa => 'Num', ); option 'custom1' => ( is => 'rw', isa => 'Test03::Type::Custom1', ); option 'custom2' => ( is => 'rw', isa => 'Test03::Type::Custom2', coerce => 1, ); option 'split' => ( is => 'rw', isa => 'ArrayRef[Str]', cmd_split => qr/;/i, ); option 'count' => ( is => 'rw', cmd_count => 1, ); option ['extra1','extra2'] => ( is => 'rw', ); sub run { my ($self) = @_; } 1;MooseX-App-1.39/t/testlib/Test03/BrokenCommand.pm000644 000765 000024 00000000541 12215374470 021737 0ustar00marosstaff000000 000000 package Test03::BrokenCommand; use MooseX::App::Command; option 'conflict1' => ( is => 'rw', isa => 'Bool', cmd_flag => 'conflict', ); option 'conflict2' => ( is => 'rw', isa => 'Bool', cmd_flag => 'conflict', default => 1, ); sub run { my ($self) = @_; } 1;MooseX-App-1.39/t/testlib/Test03/DifferentCommand.pm000644 000765 000024 00000001112 12520617604 022416 0ustar00marosstaff000000 000000 package Test03::DifferentCommand; use MooseX::App::Command; extends qw(Test03CommandBase); option 'hash' => ( is => 'rw', isa => 'HashRef', ); option 'integer' => ( is => 'rw', isa => 'Int', ); option 'list' => ( is => 'rw', isa => 'ArrayRef', ); option 'string' => ( is => 'rw', isa => 'Str', ); sub run { my ($self) = @_; use Data::Dumper; { local $Data::Dumper::Maxdepth = 2; warn __FILE__.':line'.__LINE__.':'.Dumper($self); } } 1;MooseX-App-1.39/t/testlib/Test03/ExtraCommand.pm000644 000765 000024 00000001531 12454262633 021604 0ustar00marosstaff000000 000000 package Test03::ExtraCommand; use MooseX::App::Command; parameter 'extra1' => ( is => 'rw', isa => 'Str', required => 1, documentation => q[Important extra parameter], ); parameter 'extra2' => ( is => 'rw', isa => 'Int', ); parameter 'alpha' => ( is => 'rw', isa => 'Int', ); option 'value' => ( is => 'rw', isa => 'Str', required => 1, default => sub { return "hase" }, ); option 'flag' => ( is => 'rw', isa => 'Bool', ); option 'flaggo' => ( is => 'rw', isa => 'Bool', ); sub run { my ($self) = @_; use Data::Dumper; { local $Data::Dumper::Maxdepth = 2; warn __FILE__.':line'.__LINE__.':'.Dumper($self); } } 1; MooseX-App-1.39/t/testlib/Test03/Role/000755 000765 000024 00000000000 13161707310 017555 5ustar00marosstaff000000 000000 MooseX-App-1.39/t/testlib/Test03/SomeCommand.pm000644 000765 000024 00000001665 13025562666 021440 0ustar00marosstaff000000 000000 package Test03::SomeCommand; use MooseX::App::Command; extends qw(Test03); with qw(Test03::Role::TestRole); use Moose::Util::TypeConstraints; parameter 'param_a' => ( is => 'rw', isa => 'Str', ); parameter 'param_b' => ( is => 'rw', isa => enum([qw(aaa bbb ccc ddd eee fff)]), ); option 'some_option' => ( is => 'rw', isa => 'Str', documentation => q[Very important option!], ); option 'another_option' => ( is => 'rw', isa => 'Str', required => 1, cmd_flag => 'another', cmd_tags => ['Not important'], ); option 'list' => ( is => 'rw', isa => 'ArrayRef[Maybe[Str]]', ); has 'private' => ( is => 'rw', isa => 'Str', ); sub run { my ($self) = @_; print "RUN:".($self->some_option||'').":".($self->another_option||''); } 1;MooseX-App-1.39/t/testlib/Test03/YetAnotherCommand.pm000644 000765 000024 00000001463 13025562666 022613 0ustar00marosstaff000000 000000 package Test03::YetAnotherCommand; use MooseX::App::Command; extends qw(Test03CommandBase); with qw(MooseX::App::Role::Common); option 'bool1' => ( is => 'rw', isa => 'Bool', cmd_flag => 'a', ); option 'bool2' => ( is => 'rw', isa => 'Bool', cmd_flag => 'b', default => 1, ); option 'bool3' => ( is => 'rw', isa => 'Bool', required => 1, cmd_negate => ['no-bool3'], ); option 'value' => ( is => 'rw', isa => 'Str', required => 1, default => sub { return "hase" }, ); sub run { my ($self) = @_; use Data::Dumper; { local $Data::Dumper::Maxdepth = 2; warn __FILE__.':line'.__LINE__.':'.Dumper($self); } } 1;MooseX-App-1.39/t/testlib/Test03/Role/TestRole.pm000644 000765 000024 00000000710 12454262633 021662 0ustar00marosstaff000000 000000 # ============================================================================ package Test03::Role::TestRole; # ============================================================================ use utf8; use namespace::autoclean; use MooseX::App::Role; option 'roleattr' => ( is => 'rw', isa => 'Str', cmd_tags => ['Role'], ); parameter 'param_c' => ( is => 'rw', isa => 'Str', ); 1;MooseX-App-1.39/t/testlib/Test02/Command/000755 000765 000024 00000000000 13161707310 020231 5ustar00marosstaff000000 000000 MooseX-App-1.39/t/testlib/Test02/MoreCommands/000755 000765 000024 00000000000 13161707310 021237 5ustar00marosstaff000000 000000 MooseX-App-1.39/t/testlib/Test02/MoreCommands/Test.pm000644 000765 000024 00000001115 12454262644 022524 0ustar00marosstaff000000 000000 # ============================================================================ package Test02::MoreCommands::Test; # ============================================================================ use strict; use warnings; use utf8; use Moose; use MooseX::App::Command; extends qw(Test02); use Moose::Util::TypeConstraints; parameter 'first' => ( isa => enum([qw(a1 b2 b3)]), is => 'rw', required => 1, cmd_term => 1, ); option 'second' => ( isa => 'Int', is => 'rw', cmd_term => 1, ); 1;MooseX-App-1.39/t/testlib/Test02/Command/Error.pm000644 000765 000024 00000000533 12520455702 021664 0ustar00marosstaff000000 000000 package Test02::Command::Error; use Moose; use MooseX::App::Command; extends qw(Test02); sub BUILD { warn('XXX'); exit 25; } sub run { warn('YYY'); exit 77; } command_usage "Use me not"; command_long_description "A very long description about a command that will always fail"; command_short_description "Short description"; 1;MooseX-App-1.39/t/testlib/Test02/Command/Record.pm000644 000765 000024 00000000137 12056145645 022017 0ustar00marosstaff000000 000000 package Test02::Command::Record; use Moose; use MooseX::App::Command; extends qw(Test02); 1;MooseX-App-1.39/t/testlib/Test02/Command/Required.pm000644 000765 000024 00000000561 12454262644 022363 0ustar00marosstaff000000 000000 package Test02::Command::Required; use Moose; use MooseX::App::Command; extends qw(Test02); option 'local1' => ( isa => 'Int', is => 'rw', required => 1, cmd_term => 1, ); option 'local2' => ( isa => 'Bool', is => 'rw', default => 1, cmd_term => 1, ); 1;MooseX-App-1.39/t/testlib/Test01/CommandA.pm000644 000765 000024 00000001764 13025562666 020713 0ustar00marosstaff000000 000000 package Test01::CommandA; use Moose; use MooseX::App::Command; extends qw(Test01); option 'command_local1' => ( isa => 'Int', is => 'rw', documentation => 'some docs about the long texts that seem to occur randomly', cmd_tags => [qw(Important)], cmd_env => 'LOCAL1', ); option 'command_local2' => ( isa => 'Str', is => 'rw', documentation => q[Verylongwordwithoutwhitespacestotestiftextformatingworksproperly], cmd_env => 'LOCAL2', ); has 'anotherprivate' => ( is => 'rw', isa => 'Str', ); command_long_description "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Cras dui velit, varius nec iaculis vitae, elementum eget mi. * bullet1 * bullet2 * bullet3 Cras eget mi nisi. In hac habitasse platea dictumst."; command_short_description "Command A!"; sub run { my ($self) = @_; print "RUN COMMAND-A:".($self->command_local2 // 'undef'); } 1;MooseX-App-1.39/t/testlib/Test01/CommandB.pm000644 000765 000024 00000001601 13037503110 020660 0ustar00marosstaff000000 000000 package Test01::CommandB; use Moose; use MooseX::App::Command; extends qw(Test01); use Moose::Util::TypeConstraints; has 'param_a' => ( isa => 'Str', is => 'rw', ); option 'param_b' => ( isa => enum([qw(aaa bbb ccc ddd eee fff)]), is => 'rw', required => 1, ); sub run { print "RUN COMMAND-B"; } =encoding utf8 =head1 NAME Test01::CommandB - Test class command B for test 01 =head1 SYNOPSIS use with care =head1 DESCRIPTION Some description of B some code some code =head2 SUB HEADLINE some more desc =over =item * item 1 =item * item 2 =over =item * item 2.1 =item * item 2.2 =back =back hase ist so super and this is a very long sentence witch breaks after i have written some bla bla. another interesting paragraph. =head1 METHODS hase =head2 SUB A bär =head1 SUB B some methods =cut 1;MooseX-App-1.39/t/testlib/Test01/CommandC1.pm000644 000765 000024 00000000401 12217341316 020746 0ustar00marosstaff000000 000000 package Test01::CommandC1 ; use Moose; use MooseX::App::Command; extends qw(Test01); option 'param_internal_name' => ( isa => 'Str', is => 'rw', cmd_flag => 'external_name', required => 1, ); # ABSTRACT: Test C1 1;MooseX-App-1.39/t/testlib/Test01/CommandD.pm000644 000765 000024 00000001602 13037503110 020663 0ustar00marosstaff000000 000000 package Test01::CommandD; use Moose; use MooseX::App::Command; extends qw(Test01); use Moose::Util::TypeConstraints; subtype 'ArrayRefOfInts', as 'ArrayRef[Int]'; coerce 'ArrayRefOfInts', from 'Int', via { [ $_ ] }; option 'command_local1' => ( isa => 'ArrayRefOfInts', coerce => 1, is => 'rw', documentation => 'some docs about the long texts that seem to occur randomly', cmd_tags => [qw(Important)], cmd_env => 'LOCAL1', ); command_long_description "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Cras dui velit, varius nec iaculis vitae, elementum eget mi. * bullet1 * bullet2 * bullet3 Cras eget mi nisi. In hac habitasse platea dictumst."; command_short_description "Command A!"; sub run { my ($self) = @_; print "RUN COMMAND-D:".($self->command_local1 // 'undef'); } 1;MooseX-App-1.39/t/example/test01.pl000755 000765 000024 00000000254 12075527062 017247 0ustar00marosstaff000000 000000 #!/usr/bin/env perl use strict; use warnings; use 5.010; use FindBin qw(); use lib $FindBin::Bin.'/../testlib'; use Test01; Test01->new_with_command( global => 1 )->run;MooseX-App-1.39/t/example/test02.pl000755 000765 000024 00000000235 12074052212 017234 0ustar00marosstaff000000 000000 #!/usr/bin/env perl use strict; use warnings; use 5.010; use FindBin qw(); use lib $FindBin::Bin.'/../testlib'; use Test02; Test02->new_with_command->run;MooseX-App-1.39/t/example/test03.pl000755 000765 000024 00000000235 12074052212 017235 0ustar00marosstaff000000 000000 #!/usr/bin/env perl use strict; use warnings; use 5.010; use FindBin qw(); use lib $FindBin::Bin.'/../testlib'; use Test03; Test03->new_with_command->run;MooseX-App-1.39/t/example/test04.pl000755 000765 000024 00000000235 12074052212 017236 0ustar00marosstaff000000 000000 #!/usr/bin/env perl use strict; use warnings; use 5.010; use FindBin qw(); use lib $FindBin::Bin.'/../testlib'; use Test04; Test04->new_with_command->run;MooseX-App-1.39/t/example/test05.pl000755 000765 000024 00000000235 12074052271 017244 0ustar00marosstaff000000 000000 #!/usr/bin/env perl use strict; use warnings; use 5.010; use FindBin qw(); use lib $FindBin::Bin.'/../testlib'; use Test05; Test05->new_with_options->run;MooseX-App-1.39/t/example/test06.pl000755 000765 000024 00000000235 12074052241 017242 0ustar00marosstaff000000 000000 #!/usr/bin/env perl use strict; use warnings; use 5.010; use FindBin qw(); use lib $FindBin::Bin.'/../testlib'; use Test06; Test06->new_with_command->run;MooseX-App-1.39/t/example/test07.pl000755 000765 000024 00000000235 12520455702 017250 0ustar00marosstaff000000 000000 #!/usr/bin/env perl use strict; use warnings; use 5.010; use FindBin qw(); use lib $FindBin::Bin.'/../testlib'; use Test07; Test07->new_with_options->run;MooseX-App-1.39/t/example/test08.pl000755 000765 000024 00000000235 12520455702 017251 0ustar00marosstaff000000 000000 #!/usr/bin/env perl use strict; use warnings; use 5.010; use FindBin qw(); use lib $FindBin::Bin.'/../testlib'; use Test08; Test08->new_with_options->run;MooseX-App-1.39/lib/MooseX/000755 000765 000024 00000000000 13161707310 015641 5ustar00marosstaff000000 000000 MooseX-App-1.39/lib/MooseX/App/000755 000765 000024 00000000000 13161707310 016361 5ustar00marosstaff000000 000000 MooseX-App-1.39/lib/MooseX/App.pm000644 000765 000024 00000046742 13161707111 016733 0ustar00marosstaff000000 000000 # ============================================================================« package MooseX::App; # ============================================================================« use 5.010; use utf8; use strict; use warnings; our $AUTHORITY = 'cpan:MAROS'; our $VERSION = 1.39; use MooseX::App::Meta::Role::Attribute::Option; use MooseX::App::Exporter qw(app_usage app_description app_base app_fuzzy app_strict app_prefer_commandline app_permute option parameter); use MooseX::App::Message::Envelope; use Moose::Exporter; use Scalar::Util qw(blessed); my ($IMPORT,$UNIMPORT,$INIT_META) = Moose::Exporter->build_import_methods( with_meta => [ qw(app_usage app_description app_namespace app_exclude app_base app_fuzzy app_command_name app_command_register app_strict app_prefer_commandline option parameter app_permute) ], also => [ 'Moose' ], as_is => [ 'new_with_command' ], install => [ 'unimport','init_meta' ], ); sub import { my ( $class, @plugins ) = @_; # Get caller my ($caller_class) = caller(); # Process plugins MooseX::App::Exporter->process_plugins($caller_class,@plugins); # Call Moose-Exporter generated importer return $class->$IMPORT( { into => $caller_class } ); } sub init_meta { my ($class,%args) = @_; # Get required roles and metaroles $args{roles} = ['MooseX::App::Role::Base']; $args{metaroles} = { class => [ 'MooseX::App::Meta::Role::Class::Base', 'MooseX::App::Meta::Role::Class::Documentation' ], attribute => [ 'MooseX::App::Meta::Role::Attribute::Option' ], }; return MooseX::App::Exporter->process_init_meta(%args); } sub app_command_name(&) { my ( $meta, $namesub ) = @_; return $meta->app_command_name($namesub); } sub app_command_register(%) { my ( $meta, %commands ) = @_; foreach my $command (keys %commands) { $meta->command_register($command,$commands{$command}); } return; } sub app_namespace(@) { my ( $meta, @namespaces ) = @_; return $meta->app_namespace( \@namespaces ); } sub app_exclude(@) { my ( $meta, @namespaces ) = @_; return $meta->app_exclude( \@namespaces ); } sub new_with_command { my ($class,@args) = @_; Moose->throw_error('new_with_command is a class method') if ! defined $class || blessed($class); my $meta = $class->meta; my $metameta = $meta->meta; # Sanity check Moose->throw_error('new_with_command may only be called from the application base package:'.$class) if $metameta->does_role('MooseX::App::Meta::Role::Class::Command') || ! $metameta->does_role('MooseX::App::Meta::Role::Class::Base'); $meta->command_check() if $ENV{APP_DEVELOPER} || $ENV{HARNESS_ACTIVE}; # Extra args my %args; if (scalar @args == 1 && ref($args[0]) eq 'HASH' ) { %args = %{$args[0]}; } elsif (scalar @args % 2 == 0) { %args = @args; } else { Moose->throw_error('new_with_command got invalid extra arguments'); } # Get ARGV my $argv = delete $args{ARGV}; my $parsed_argv; if (defined $argv) { $parsed_argv = MooseX::App::ParsedArgv->new( argv => $argv ); } else { $parsed_argv = MooseX::App::ParsedArgv->instance(); } my $first_argv = $parsed_argv->first_argv; # Requested help if (defined $first_argv && lc($first_argv) =~ m/^(help|h|\?|usage|-h|--help|-\?|--usage)$/) { return MooseX::App::Message::Envelope->new( $meta->command_usage_global(), ); # No args } elsif (! defined $first_argv || $first_argv =~ m/^\s*$/ || $first_argv =~ m/^-{1,2}\w/) { return MooseX::App::Message::Envelope->new( $meta->command_message( header => "Missing command", # LOCALIZE type => "error", ), $meta->command_usage_global(), 127, # exitcode ); # Looks like a command } else { my $return = $meta->command_find(); # Nothing found if (blessed $return && $return->isa('MooseX::App::Message::Block')) { return MooseX::App::Message::Envelope->new( $return, $meta->command_usage_global(), 127, # exitcode ); # One command found } else { my $command_class = $meta->command_get($return); return $class->initialize_command_class($command_class,%args); } } } no Moose; 1; __END__ =encoding utf8 =head1 NAME MooseX::App - Write user-friendly command line apps with even less suffering =head1 SYNOPSIS In your base class: package MyApp; use MooseX::App qw(Color); option 'global_option' => ( is => 'rw', isa => 'Bool', documentation => q[Enable this to do fancy stuff], ); # Global option has 'private' => ( is => 'rw', ); # not exposed Write multiple command classes (If you have only a single command class you should use L instead). Packackes in the namespace may be deeply nested. package MyApp::SomeCommand; use MooseX::App::Command; # important (also imports Moose) extends qw(MyApp); # optional, only if you want to use global options from base class # Positional parameter parameter 'some_parameter' => ( is => 'rw', isa => 'Str', required => 1, documentation => q[Some parameter that you need to supply], ); option 'some_option' => ( is => 'rw', isa => 'Int', required => 1, documentation => q[Very important option!], ); # Option sub run { my ($self) = @_; # Do something } And then you need a simple wrapper script (called eg. myapp): #!/usr/bin/env perl use MyApp; MyApp->new_with_command->run; On the command line: bash$ myapp help usage: myapp [long options...] myapp help global options: --global_option Enable this to do fancy stuff [Flag] --help --usage -? Prints this usage information. [Flag] available commands: some_command Description of some command another_command Description of another command help Prints this usage information or bash$ myapp some_command --help usage: myapp some_command [long options...] myapp help myapp some_command --help parameters: some_parameter Some parameter that you need to supply [Required] options: --global_option Enable this to do fancy stuff [Flag] --some_option Very important option! [Int,Required] --help --usage -? Prints this usage information. [Flag] =head1 DESCRIPTION MooseX-App is a highly customisable helper to write user-friendly command line applications without having to worry about most of the annoying things usually involved. Just take any existing L class, add a single line (C) and create one class for each command in an underlying namespace. Options and positional parameters can be defined as simple L accessors using the C