MouseX-Getopt-0.34000755000765000024 011732225161 13170 5ustar00gfxstaff000000000000README100644000765000024 50711732225161 14113 0ustar00gfxstaff000000000000MouseX-Getopt-0.34 This archive contains the distribution MouseX-Getopt, version 0.34: A Mouse role for processing command line options This software is copyright (c) 2012 by Infinity Interactive, Inc. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. LICENSE100644000765000024 4372211732225161 14306 0ustar00gfxstaff000000000000MouseX-Getopt-0.34This software is copyright (c) 2012 by Infinity Interactive, Inc. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. Terms of the Perl programming language system itself a) the GNU General Public License as published by the Free Software Foundation; either version 1, or (at your option) any later version, or b) the "Artistic License" --- The GNU General Public License, Version 1, February 1989 --- This software is Copyright (c) 2012 by Infinity Interactive, Inc. This is free software, licensed under: The GNU General Public License, Version 1, February 1989 GNU GENERAL PUBLIC LICENSE Version 1, February 1989 Copyright (C) 1989 Free Software Foundation, Inc. 51 Franklin St, Suite 500, Boston, MA 02110-1335 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The license agreements of most software companies try to keep users at the mercy of those companies. By contrast, our General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. The General Public License applies to the Free Software Foundation's software and to any other program whose authors commit to using it. You can use it for your programs, too. When we speak of free software, we are referring to freedom, not price. Specifically, the General Public License is designed to make sure that you have the freedom to give away or sell copies of free software, that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of a such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must tell them their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. The precise terms and conditions for copying, distribution and modification follow. GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License Agreement applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any work containing the Program or a portion of it, either verbatim or with modifications. Each licensee is addressed as "you". 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this General Public License and to the absence of any warranty; and give any other recipients of the Program a copy of this General Public License along with the Program. You may charge a fee for the physical act of transferring a copy. 2. You may modify your copy or copies of the Program or any portion of it, and copy and distribute such modifications under the terms of Paragraph 1 above, provided that you also do the following: a) cause the modified files to carry prominent notices stating that you changed the files and the date of any change; and b) cause the whole of any work that you distribute or publish, that in whole or in part contains the Program or any part thereof, either with or without modifications, to be licensed at no charge to all third parties under the terms of this General Public License (except that you may choose to grant warranty protection to some or all third parties, at your option). c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the simplest and most usual way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this General Public License. d) You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. Mere aggregation of another independent work with the Program (or its derivative) on a volume of a storage or distribution medium does not bring the other work under the scope of these terms. 3. You may copy and distribute the Program (or a portion or derivative of it, under Paragraph 2) in object code or executable form under the terms of Paragraphs 1 and 2 above provided that you also do one of the following: a) accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Paragraphs 1 and 2 above; or, b) accompany it with a written offer, valid for at least three years, to give any third party free (except for a nominal charge for the cost of distribution) a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Paragraphs 1 and 2 above; or, c) accompany it with the information you received as to where the corresponding source code may be obtained. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form alone.) Source code for a work means the preferred form of the work for making modifications to it. For an executable file, complete source code means all the source code for all modules it contains; but, as a special exception, it need not include source code for modules which are standard libraries that accompany the operating system on which the executable file runs, or for standard header files or definitions files that accompany that operating system. 4. You may not copy, modify, sublicense, distribute or transfer the Program except as expressly provided under this General Public License. Any attempt otherwise to copy, modify, sublicense, distribute or transfer the Program is void, and will automatically terminate your rights to use the Program under this License. However, parties who have received copies, or rights to use copies, from you under this General Public License will not have their licenses terminated so long as such parties remain in full compliance. 5. By copying, distributing or modifying the Program (or any work based on the Program) you indicate your acceptance of this license to do so, and all its terms and conditions. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. 7. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies a version number of the license which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of the license, you may choose any version ever published by the Free Software Foundation. 8. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 9. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 10. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS Appendix: How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to humanity, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) 19yy This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 1, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301 USA Also add information on how to contact you by electronic and paper mail. If the program is interactive, make it output a short notice like this when it starts in an interactive mode: Gnomovision version 69, Copyright (C) 19xx name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than `show w' and `show c'; they could even be mouse-clicks or menu items--whatever suits your program. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision' (a program to direct compilers to make passes at assemblers) written by James Hacker. , 1 April 1989 Ty Coon, President of Vice That's all there is to it! --- The Artistic License 1.0 --- This software is Copyright (c) 2012 by Infinity Interactive, Inc. This is free software, licensed under: The Artistic License 1.0 The Artistic License Preamble The intent of this document is to state the conditions under which a Package may be copied, such that the Copyright Holder maintains some semblance of artistic control over the development of the package, while giving the users of the package the right to use and distribute the Package in a more-or-less customary fashion, plus the right to make reasonable modifications. Definitions: - "Package" refers to the collection of files distributed by the Copyright Holder, and derivatives of that collection of files created through textual modification. - "Standard Version" refers to such a Package if it has not been modified, or has been modified in accordance with the wishes of the Copyright Holder. - "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. The name of the Copyright Holder may not be used to endorse or promote products derived from this software without specific prior written permission. 9. 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 dist.ini100644000765000024 170211732225161 14715 0ustar00gfxstaff000000000000MouseX-Getopt-0.34name = MouseX-Getopt version = 0.34 author = NAKAGAWA Masaki author = FUJI Goro author = Stevan Little author = Brandon L. Black author = Yuval Kogman author = Ryan D Johnson author = Drew Taylor author = Tomas Doran author = Florian Ragwitz author = Dagfinn Ilmari Mannsaker author = Avar Arnfjord Bjarmason author = Chris Prather author = Mark Gardner license = Perl_5 copyright_holder = Infinity Interactive, Inc [@FLORA] dist = MouseX-Getopt repository_at = github github_user = gfx authority = cpan:STEVAN auto_prereq = 0 [Prereqs] Getopt::Long = 2.37 Getopt::Long::Descriptive = 0.091 Mouse = 0.64 [Prereqs / TestRequires] Test::Exception = 0.21 Test::Warn = 0.21 Test::More = 0.88 META.yml100644000765000024 1171011732225161 14542 0ustar00gfxstaff000000000000MouseX-Getopt-0.34--- abstract: 'A Mouse role for processing command line options' author: - 'NAKAGAWA Masaki ' - 'FUJI Goro ' - 'Stevan Little ' - 'Brandon L. Black ' - 'Yuval Kogman ' - 'Ryan D Johnson ' - 'Drew Taylor ' - 'Tomas Doran ' - 'Florian Ragwitz ' - 'Dagfinn Ilmari Mannsaker ' - 'Avar Arnfjord Bjarmason ' - 'Chris Prather ' - 'Mark Gardner ' build_requires: Test::Exception: 0.21 Test::More: 0.88 Test::Warn: 0.21 configure_requires: ExtUtils::MakeMaker: 6.30 dynamic_config: 0 generated_by: 'Dist::Zilla version 4.300010, CPAN::Meta::Converter version 2.120630' license: perl meta-spec: url: http://module-build.sourceforge.net/META-spec-v1.4.html version: 1.4 name: MouseX-Getopt requires: Getopt::Long: 2.37 Getopt::Long::Descriptive: 0.091 Mouse: 0.64 resources: bugtracker: http://rt.cpan.org/Public/Dist/Display.html?Name=MouseX-Getopt homepage: http://metacpan.org/release/MouseX-Getopt repository: git://github.com/gfx/mousex-getopt.git version: 0.34 x_Dist_Zilla: plugins: - class: Dist::Zilla::Plugin::GatherDir name: '@FLORA/@Basic/GatherDir' version: 4.300010 - class: Dist::Zilla::Plugin::PruneCruft name: '@FLORA/@Basic/PruneCruft' version: 4.300010 - class: Dist::Zilla::Plugin::ManifestSkip name: '@FLORA/@Basic/ManifestSkip' version: 4.300010 - class: Dist::Zilla::Plugin::MetaYAML name: '@FLORA/@Basic/MetaYAML' version: 4.300010 - class: Dist::Zilla::Plugin::License name: '@FLORA/@Basic/License' version: 4.300010 - class: Dist::Zilla::Plugin::Readme name: '@FLORA/@Basic/Readme' version: 4.300010 - class: Dist::Zilla::Plugin::ExtraTests name: '@FLORA/@Basic/ExtraTests' version: 4.300010 - class: Dist::Zilla::Plugin::ExecDir name: '@FLORA/@Basic/ExecDir' version: 4.300010 - class: Dist::Zilla::Plugin::ShareDir name: '@FLORA/@Basic/ShareDir' version: 4.300010 - class: Dist::Zilla::Plugin::MakeMaker name: '@FLORA/@Basic/MakeMaker' version: 4.300010 - class: Dist::Zilla::Plugin::Manifest name: '@FLORA/@Basic/Manifest' version: 4.300010 - class: Dist::Zilla::Plugin::TestRelease name: '@FLORA/@Basic/TestRelease' version: 4.300010 - class: Dist::Zilla::Plugin::ConfirmRelease name: '@FLORA/@Basic/ConfirmRelease' version: 4.300010 - class: Dist::Zilla::Plugin::UploadToCPAN name: '@FLORA/@Basic/UploadToCPAN' version: 4.300010 - class: Dist::Zilla::Plugin::MetaConfig name: '@FLORA/MetaConfig' version: 4.300010 - class: Dist::Zilla::Plugin::MetaJSON name: '@FLORA/MetaJSON' version: 4.300010 - class: Dist::Zilla::Plugin::PkgVersion name: '@FLORA/PkgVersion' version: 4.300010 - class: Dist::Zilla::Plugin::PodSyntaxTests name: '@FLORA/PodSyntaxTests' version: 4.300010 - class: Dist::Zilla::Plugin::NoTabsTests name: '@FLORA/NoTabsTests' version: 0.01 - class: Dist::Zilla::Plugin::PodCoverageTests name: '@FLORA/PodCoverageTests' version: 4.300010 - class: Dist::Zilla::Plugin::MetaResources name: '@FLORA/MetaResources' version: 4.300010 - class: Dist::Zilla::Plugin::Authority name: '@FLORA/Authority' version: 1.006 - class: Dist::Zilla::Plugin::EOLTests name: '@FLORA/EOLTests' version: 0.02 - class: Dist::Zilla::Plugin::PodWeaver name: '@FLORA/PodWeaver' version: 3.101641 - class: Dist::Zilla::Plugin::Prereqs config: Dist::Zilla::Plugin::Prereqs: phase: runtime type: requires name: Prereqs version: 4.300010 - class: Dist::Zilla::Plugin::Prereqs config: Dist::Zilla::Plugin::Prereqs: phase: test type: requires name: TestRequires version: 4.300010 - class: Dist::Zilla::Plugin::FinderCode name: ':InstallModules' version: 4.300010 - class: Dist::Zilla::Plugin::FinderCode name: ':IncModules' version: 4.300010 - class: Dist::Zilla::Plugin::FinderCode name: ':TestFiles' version: 4.300010 - class: Dist::Zilla::Plugin::FinderCode name: ':ExecFiles' version: 4.300010 - class: Dist::Zilla::Plugin::FinderCode name: ':ShareFiles' version: 4.300010 - class: Dist::Zilla::Plugin::FinderCode name: ':MainModule' version: 4.300010 zilla: class: Dist::Zilla::Dist::Builder config: is_trial: 0 version: 4.300010 x_authority: cpan:STEVAN MANIFEST100644000765000024 172711732225161 14411 0ustar00gfxstaff000000000000MouseX-Getopt-0.34ChangeLog ChangeLog~ LICENSE MANIFEST META.json META.yml Makefile.PL README dist.ini dist.ini~ lib/MouseX/Getopt.pm lib/MouseX/Getopt/Basic.pm lib/MouseX/Getopt/Dashes.pm lib/MouseX/Getopt/GLD.pm lib/MouseX/Getopt/Meta/Attribute.pm lib/MouseX/Getopt/Meta/Attribute/NoGetopt.pm lib/MouseX/Getopt/Meta/Attribute/Trait.pm lib/MouseX/Getopt/Meta/Attribute/Trait/NoGetopt.pm lib/MouseX/Getopt/OptionTypeMap.pm lib/MouseX/Getopt/Strict.pm t/000_load.t t/001_basic.t t/002_custom_option_type.t t/003_inferred_option_type.t t/004_nogetop.t t/005_strict.t t/006_metaclass_traits.t t/007_nogetopt_trait.t t/008_configfromfile.t t/009_gld_and_explicit_options.t t/010_dashes.t t/100_gld_default_bug.t t/101_argv_bug.t t/102_basic_basic.t t/103_uc_bug.t t/104_override_usage.t t/105_uc_bug_more.t t/106_no_ignore_case.t t/107_no_auto_help.t t/108_usage_attr.t t/109_help_flag.t t/110_sort_usage_by_attr_order.t t/release-eol.t t/release-no-tabs.t t/release-pod-coverage.t t/release-pod-syntax.t ChangeLog100644000765000024 2135411732225161 15050 0ustar00gfxstaff000000000000MouseX-Getopt-0.34Revision history for Perl extension MouseX-Getopt 0.34 2012-03-21 10:04:14 * fix configfromfile test to use new Getopt::Long::Descriptive text (mjgardner) 0.33 Sat Jul 31 10:09:23 JST 2010 * (no feature change) re-release to fix unauthorized release 0.32 Thu Jul 29 20:21:56 JST 2010 * added workaround for $@ issue in Data::Util. 0.31 Mon Jul 26 20:52:38 2010 * Just copied from MooseX-Getopt 0.31. See MouseX-Getopt.diff for details. NOTE: This distribution is a copy of MooseX-Getopt, so the following history is that of MooseX-Getopt's, not MouseX-Geopt's. 0.31 Wed 7 Jul 2010 * Fix issue causing tests to fail if MooseX::SimpleConfig isn't installed. 0.30 Tue 6 Jul 2010 * MooseX::Getopt::Basic - uses attribute insertion order when determining the order in which options are documented in the usage (e.g. in $obj->usage->text). (Karen Etheridge) * MooseX::Getopt::Basic - store the usage object to the usage attr (RT#58715) - properly checks whether the *option* --help, --usage, or --? were used, rather than the attribute 'help', 'usage' or '?' were set * MooseX::Getopt::GLD - add the usage attribute for storing the Getopt::Long::Descriptive::Usage object, and the help attribute for storing --help, --usage and --? state (RT#47865, RT#56783, RT#52474). (Karen Etheridge) * MooseX::Getopt::Basic - Disable auto_help config in Getopt::Long, to avoid calling into pod2usage when the --help option is used while MooseX::ConfigFromFile is in use (the intent is just to fetch the value of the configfile option) (RT#57683). (Karen Etheridge) 0.29 Tue. Jun 15 2010 * Fix repository metadata. Thanks Robert Bohne for noticing! 0.28 Sat. Jun 05 2010 * MooseX::Getopt::Strict - Make it work with Getopt attribute traits in addition to attribute metaclasses. * Switch from Module::Install to Dist::Zilla. 0.27 Sun. Feb 10 2010 * Makefile.PL: - Bump dependency to Getopt::Long::Descriptive to 0.081 in an attempt to avoid test failures. * MooseX::Getopt::Dashes - Document that using a cmd_flag argument to attributes can be used to override the tr/_/-/ replacement ::Dashes does on attribute names 0.26 Thu. Dec 10 2009 * MooseX::Getopt::Basic - Fix bug with attribute names containing upper case letters. * Test suite: - Add t/106_no_ignore_case.t for testing the compatibility with no_ignore_case 0.25 Thu. Nov 26 2009 * MooseX::Getopt - Split out the warnings and the exception from Getopt so that they can be overridden. - Split out calling ->die on Getopt::Long::Descriptive::Usage so that it can be overridden. - Properly split roles as promised in 0.22. 0.24 Fri. Oct 23 2009 * MooseX::Getopt - Fix bug with mixed case attribute names (MAROS) 0.23 Fri. Oct 02 2009 * MooseX::Getopt - Allow the config file to return a code ref which is called to return the config file location (Gordon Irving) 0.22 Sat. Sept 05 2009 - Require GLD 0.077 for RT#49427 as some versions are broken * MooseX::Getopt - Split into MooseX::Getopt::Basic (without the G::L::Descriptive support) and MooseX::Getopt::GLD. * Tests - Ensure author tests get run when in author mode. 0.21 Thu. Aug 27 2009 * MooseX::Getopt - Enable and document the argv parameter to the constructor. - Applied patches in RT43200 and RT43255 - Applied patch from RT#47766 to not die if SimpleConfig cannot find the default config file name. 0.20 Wed. July 9 2009 - fix MANIFEST.SKIP to avoid double-packaging 0.19 Wed. July 8 2009 * MooseX::Getopt - Fix Getopt config spec for --configfile (t0m) - Add support for --usage/--help/--? (drew@drewtaylor.com) - Fix new_with_options to accept a hashref (DOUGDUDE@cpan.org) * Tests - Fix warning from tests with new Moose (t0m) - Fix tests on Win32 from RT#44909 (taro-nishino) 0.18 Thu. April 9 2009 * MooseX::Getopt::Dashes - New module, for converting undercores to dashes (ilmari) 0.17 Wed. April 8 2009 * MooseX::Getopt - work with latest Moose (hdp) ~ unify module version numbers with dist version (hdp) 0.16 Tue. February 17 2009 * t/ - run pod tests only if RELEASE_TESTING env var is set 0.15 Sat. July 26 2008 * MooseX::Getopt::OptionTypeMap - Accept type constraint objects in the type mapping, not just names 0.14 Thurs. July 10, 2008 * MooseX::Getopt::OptionTypeMap - Change 'Float' which doesn't exist to 'Num' which does (perigrin) * MooseX::Getopt - removed the default handling with Getopt::Long::Descriptive as it would override constructor parameters and that was bad. Besides, Moose will just DWIM on this anyway. (stevan) - added test for it (stevan) * t/ - fixed Getopt::Long::Descriptive specific tests to only run if Getopt::Long::Descriptive is there (stevan) 0.13 Saturday, May 24, 2008 * MooseX::Getopt - Commandline option shouldn't be required in the case that the given "required" attribute has been loaded from config (MooseX::ConfigFromFile) - Support for MooseX::ConfigFromFile shouldn't require that role be added at the same level as Getopt. - fixed miscapitalization of NoGetopt in the docs - added links to the traits in the docs ~ converted to Module::Install instead of Module::Build 0.12 Fri. March 14, 2008 ~~ updated copyright dates ~~ - upped the Moose dependency to support the custom metaclass traits - added Getopt::Long::Descriptive as an optional dependency * MooseX::Getopt MooseX::Getopt::Meta::Attribute MooseX::Getopt::Meta::Attribute::Trait MooseX::Getopt::Meta::Attribute::NoGetopt MooseX::Getopt::Meta::Attribute::Trait::NoGetopt - added support for custom metaclass traits - added tests for this 0.11 Sun. Jan. 27, 2008 * MooseX::Getopt - Commandline option shouldn't be required in the case that the given "required" attribute has a default or a builder method. 0.10 Wed. Jan. 23, 2008 * MooseX::Getopt - Support default configfile attribute when used with MooseX::ConfigFromFile-based roles 0.09 Tues. Jan. 22, 2008 * MooseX::Getopt - Use Getopt::Long::Descriptive if it's available 0.08 Tues. Dec. 8, 2007 * MooseX::Getopt - Added support for configfile loading via MooseX::ConfigFromFile-based roles with the -configfile commandline option. 0.07 Tues. Dec. 4, 2007 * MooseX::Getopt::Meta::Attribute::NoGetopt - fixed miscapitalization of NoGetopt in the docs 0.06 Fri. Nov. 23, 2007 * MooseX::Getopt - refactored &new_with_option some so that this will work better with other Getopt modules (nuffin) + MooseX::Getopt::Strict - version of MooseX::Getopt which requires you to specify which attributes you want processed explicity - added tests for this + MooseX::Getopt::Meta::Attribute::NoGetopt - a custom meta-attribute which can be used to specify that an attribute should not be processed - added tests for this 0.05 Tues. July 3, 2007 * MooseX::Getopt::OptionTypeMap - added some checks to make sure that the type constraints are found properly and to give better diagnostics 0.04 Tues. June 26, 2007 * MooseX::Getopt::OptionTypeMap - Added support for subtype constraint inference from parent types - added tests and docs for this * MooseX::Getopt - Added extra_argv attribute - added tests and docs for this - We now unmangle the Getopt::Long-mangled @ARGV - added tests and docs for this - We now throw an exception from new_with_options if Getopt fails due to bad arguments. - added tests and docs for this 0.03 Wed. May 2nd, 2007 ~ downgraded the Getopt version requirement to 2.35 as per RT #26844 ~ adding blblack to the authors list * MooseX::Getopt - doc update to show simple way to of excluding an attribute, but not having accessors with underscores (thanks to Zaba on #moose for this) * MooseX::Getopt::Meta::Attribute - tightening up the type constraint in the cmd_alias coercion to only accept strings 0.02 Friday, April 6, 2007 * MooseX::Getopt - added the ARGV attribute (thanks to blblack) - added tests and docs for this * MooseX::Getopt::Meta::Attribute - added the cmd_aliases attribute (thanks to blblack) - added tests and docs for this - added support for Moose 0.19's custom attribute metaclass alias registry. - added tests and docs for this 0.01 Friday, March 9, 2007 - module released to CPAN dist.ini~100644000765000024 170111732225161 15112 0ustar00gfxstaff000000000000MouseX-Getopt-0.34name = MouseX-Getopt version = 0.34 author = NAKAGAWA Masaki author = FUJI Goro author = Stevan Little author = Brandon L. Black author = Yuval Kogman author = Ryan D Johnson author = Drew Taylor author = Tomas Doran author = Florian Ragwitz author = Dagfinn Ilmari Mannsaker author = Avar Arnfjord Bjarmason author = Chris Prather author = Mark Gardner license = Perl_5 copyright_holder = Infinity Interactive, Inc [@FLORA] dist = MouseX-Getopt repository_at = github github_user = gfx authority = cpan:STEVAN auto_prereq = 0 [Prereqs] Getopt::Long = 2.37 Getopt::Long::Descriptive = 0.091 Mouse = 0.64 [Prereq / TestRequires] Test::Exception = 0.21 Test::Warn = 0.21 Test::More = 0.88 META.json100644000765000024 1670411732225161 14722 0ustar00gfxstaff000000000000MouseX-Getopt-0.34{ "abstract" : "A Mouse role for processing command line options", "author" : [ "NAKAGAWA Masaki ", "FUJI Goro ", "Stevan Little ", "Brandon L. Black ", "Yuval Kogman ", "Ryan D Johnson ", "Drew Taylor ", "Tomas Doran ", "Florian Ragwitz ", "Dagfinn Ilmari Mannsaker ", "Avar Arnfjord Bjarmason ", "Chris Prather ", "Mark Gardner " ], "dynamic_config" : 0, "generated_by" : "Dist::Zilla version 4.300010, CPAN::Meta::Converter version 2.120630", "license" : [ "perl_5" ], "meta-spec" : { "url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec", "version" : "2" }, "name" : "MouseX-Getopt", "prereqs" : { "configure" : { "requires" : { "ExtUtils::MakeMaker" : "6.30" } }, "runtime" : { "requires" : { "Getopt::Long" : "2.37", "Getopt::Long::Descriptive" : "0.091", "Mouse" : "0.64" } }, "test" : { "requires" : { "Test::Exception" : "0.21", "Test::More" : "0.88", "Test::Warn" : "0.21" } } }, "release_status" : "stable", "resources" : { "bugtracker" : { "mailto" : "bug-MouseX-Getopt@rt.cpan.org", "web" : "http://rt.cpan.org/Public/Dist/Display.html?Name=MouseX-Getopt" }, "homepage" : "http://metacpan.org/release/MouseX-Getopt", "repository" : { "type" : "git", "url" : "git://github.com/gfx/mousex-getopt.git", "web" : "http://github.com/gfx/mousex-getopt" } }, "version" : "0.34", "x_Dist_Zilla" : { "plugins" : [ { "class" : "Dist::Zilla::Plugin::GatherDir", "name" : "@FLORA/@Basic/GatherDir", "version" : "4.300010" }, { "class" : "Dist::Zilla::Plugin::PruneCruft", "name" : "@FLORA/@Basic/PruneCruft", "version" : "4.300010" }, { "class" : "Dist::Zilla::Plugin::ManifestSkip", "name" : "@FLORA/@Basic/ManifestSkip", "version" : "4.300010" }, { "class" : "Dist::Zilla::Plugin::MetaYAML", "name" : "@FLORA/@Basic/MetaYAML", "version" : "4.300010" }, { "class" : "Dist::Zilla::Plugin::License", "name" : "@FLORA/@Basic/License", "version" : "4.300010" }, { "class" : "Dist::Zilla::Plugin::Readme", "name" : "@FLORA/@Basic/Readme", "version" : "4.300010" }, { "class" : "Dist::Zilla::Plugin::ExtraTests", "name" : "@FLORA/@Basic/ExtraTests", "version" : "4.300010" }, { "class" : "Dist::Zilla::Plugin::ExecDir", "name" : "@FLORA/@Basic/ExecDir", "version" : "4.300010" }, { "class" : "Dist::Zilla::Plugin::ShareDir", "name" : "@FLORA/@Basic/ShareDir", "version" : "4.300010" }, { "class" : "Dist::Zilla::Plugin::MakeMaker", "name" : "@FLORA/@Basic/MakeMaker", "version" : "4.300010" }, { "class" : "Dist::Zilla::Plugin::Manifest", "name" : "@FLORA/@Basic/Manifest", "version" : "4.300010" }, { "class" : "Dist::Zilla::Plugin::TestRelease", "name" : "@FLORA/@Basic/TestRelease", "version" : "4.300010" }, { "class" : "Dist::Zilla::Plugin::ConfirmRelease", "name" : "@FLORA/@Basic/ConfirmRelease", "version" : "4.300010" }, { "class" : "Dist::Zilla::Plugin::UploadToCPAN", "name" : "@FLORA/@Basic/UploadToCPAN", "version" : "4.300010" }, { "class" : "Dist::Zilla::Plugin::MetaConfig", "name" : "@FLORA/MetaConfig", "version" : "4.300010" }, { "class" : "Dist::Zilla::Plugin::MetaJSON", "name" : "@FLORA/MetaJSON", "version" : "4.300010" }, { "class" : "Dist::Zilla::Plugin::PkgVersion", "name" : "@FLORA/PkgVersion", "version" : "4.300010" }, { "class" : "Dist::Zilla::Plugin::PodSyntaxTests", "name" : "@FLORA/PodSyntaxTests", "version" : "4.300010" }, { "class" : "Dist::Zilla::Plugin::NoTabsTests", "name" : "@FLORA/NoTabsTests", "version" : "0.01" }, { "class" : "Dist::Zilla::Plugin::PodCoverageTests", "name" : "@FLORA/PodCoverageTests", "version" : "4.300010" }, { "class" : "Dist::Zilla::Plugin::MetaResources", "name" : "@FLORA/MetaResources", "version" : "4.300010" }, { "class" : "Dist::Zilla::Plugin::Authority", "name" : "@FLORA/Authority", "version" : "1.006" }, { "class" : "Dist::Zilla::Plugin::EOLTests", "name" : "@FLORA/EOLTests", "version" : "0.02" }, { "class" : "Dist::Zilla::Plugin::PodWeaver", "name" : "@FLORA/PodWeaver", "version" : "3.101641" }, { "class" : "Dist::Zilla::Plugin::Prereqs", "config" : { "Dist::Zilla::Plugin::Prereqs" : { "phase" : "runtime", "type" : "requires" } }, "name" : "Prereqs", "version" : "4.300010" }, { "class" : "Dist::Zilla::Plugin::Prereqs", "config" : { "Dist::Zilla::Plugin::Prereqs" : { "phase" : "test", "type" : "requires" } }, "name" : "TestRequires", "version" : "4.300010" }, { "class" : "Dist::Zilla::Plugin::FinderCode", "name" : ":InstallModules", "version" : "4.300010" }, { "class" : "Dist::Zilla::Plugin::FinderCode", "name" : ":IncModules", "version" : "4.300010" }, { "class" : "Dist::Zilla::Plugin::FinderCode", "name" : ":TestFiles", "version" : "4.300010" }, { "class" : "Dist::Zilla::Plugin::FinderCode", "name" : ":ExecFiles", "version" : "4.300010" }, { "class" : "Dist::Zilla::Plugin::FinderCode", "name" : ":ShareFiles", "version" : "4.300010" }, { "class" : "Dist::Zilla::Plugin::FinderCode", "name" : ":MainModule", "version" : "4.300010" } ], "zilla" : { "class" : "Dist::Zilla::Dist::Builder", "config" : { "is_trial" : "0" }, "version" : "4.300010" } }, "x_authority" : "cpan:STEVAN" } ChangeLog~100644000765000024 2117411732225161 15246 0ustar00gfxstaff000000000000MouseX-Getopt-0.34Revision history for Perl extension MouseX-Getopt 0.33 Sat Jul 31 10:09:23 JST 2010 * (no feature change) re-release to fix unauthorized release 0.32 Thu Jul 29 20:21:56 JST 2010 * added workaround for $@ issue in Data::Util. 0.31 Mon Jul 26 20:52:38 2010 * Just copied from MooseX-Getopt 0.31. See MouseX-Getopt.diff for details. NOTE: This distribution is a copy of MooseX-Getopt, so the following history is that of MooseX-Getopt's, not MouseX-Geopt's. 0.31 Wed 7 Jul 2010 * Fix issue causing tests to fail if MooseX::SimpleConfig isn't installed. 0.30 Tue 6 Jul 2010 * MooseX::Getopt::Basic - uses attribute insertion order when determining the order in which options are documented in the usage (e.g. in $obj->usage->text). (Karen Etheridge) * MooseX::Getopt::Basic - store the usage object to the usage attr (RT#58715) - properly checks whether the *option* --help, --usage, or --? were used, rather than the attribute 'help', 'usage' or '?' were set * MooseX::Getopt::GLD - add the usage attribute for storing the Getopt::Long::Descriptive::Usage object, and the help attribute for storing --help, --usage and --? state (RT#47865, RT#56783, RT#52474). (Karen Etheridge) * MooseX::Getopt::Basic - Disable auto_help config in Getopt::Long, to avoid calling into pod2usage when the --help option is used while MooseX::ConfigFromFile is in use (the intent is just to fetch the value of the configfile option) (RT#57683). (Karen Etheridge) 0.29 Tue. Jun 15 2010 * Fix repository metadata. Thanks Robert Bohne for noticing! 0.28 Sat. Jun 05 2010 * MooseX::Getopt::Strict - Make it work with Getopt attribute traits in addition to attribute metaclasses. * Switch from Module::Install to Dist::Zilla. 0.27 Sun. Feb 10 2010 * Makefile.PL: - Bump dependency to Getopt::Long::Descriptive to 0.081 in an attempt to avoid test failures. * MooseX::Getopt::Dashes - Document that using a cmd_flag argument to attributes can be used to override the tr/_/-/ replacement ::Dashes does on attribute names 0.26 Thu. Dec 10 2009 * MooseX::Getopt::Basic - Fix bug with attribute names containing upper case letters. * Test suite: - Add t/106_no_ignore_case.t for testing the compatibility with no_ignore_case 0.25 Thu. Nov 26 2009 * MooseX::Getopt - Split out the warnings and the exception from Getopt so that they can be overridden. - Split out calling ->die on Getopt::Long::Descriptive::Usage so that it can be overridden. - Properly split roles as promised in 0.22. 0.24 Fri. Oct 23 2009 * MooseX::Getopt - Fix bug with mixed case attribute names (MAROS) 0.23 Fri. Oct 02 2009 * MooseX::Getopt - Allow the config file to return a code ref which is called to return the config file location (Gordon Irving) 0.22 Sat. Sept 05 2009 - Require GLD 0.077 for RT#49427 as some versions are broken * MooseX::Getopt - Split into MooseX::Getopt::Basic (without the G::L::Descriptive support) and MooseX::Getopt::GLD. * Tests - Ensure author tests get run when in author mode. 0.21 Thu. Aug 27 2009 * MooseX::Getopt - Enable and document the argv parameter to the constructor. - Applied patches in RT43200 and RT43255 - Applied patch from RT#47766 to not die if SimpleConfig cannot find the default config file name. 0.20 Wed. July 9 2009 - fix MANIFEST.SKIP to avoid double-packaging 0.19 Wed. July 8 2009 * MooseX::Getopt - Fix Getopt config spec for --configfile (t0m) - Add support for --usage/--help/--? (drew@drewtaylor.com) - Fix new_with_options to accept a hashref (DOUGDUDE@cpan.org) * Tests - Fix warning from tests with new Moose (t0m) - Fix tests on Win32 from RT#44909 (taro-nishino) 0.18 Thu. April 9 2009 * MooseX::Getopt::Dashes - New module, for converting undercores to dashes (ilmari) 0.17 Wed. April 8 2009 * MooseX::Getopt - work with latest Moose (hdp) ~ unify module version numbers with dist version (hdp) 0.16 Tue. February 17 2009 * t/ - run pod tests only if RELEASE_TESTING env var is set 0.15 Sat. July 26 2008 * MooseX::Getopt::OptionTypeMap - Accept type constraint objects in the type mapping, not just names 0.14 Thurs. July 10, 2008 * MooseX::Getopt::OptionTypeMap - Change 'Float' which doesn't exist to 'Num' which does (perigrin) * MooseX::Getopt - removed the default handling with Getopt::Long::Descriptive as it would override constructor parameters and that was bad. Besides, Moose will just DWIM on this anyway. (stevan) - added test for it (stevan) * t/ - fixed Getopt::Long::Descriptive specific tests to only run if Getopt::Long::Descriptive is there (stevan) 0.13 Saturday, May 24, 2008 * MooseX::Getopt - Commandline option shouldn't be required in the case that the given "required" attribute has been loaded from config (MooseX::ConfigFromFile) - Support for MooseX::ConfigFromFile shouldn't require that role be added at the same level as Getopt. - fixed miscapitalization of NoGetopt in the docs - added links to the traits in the docs ~ converted to Module::Install instead of Module::Build 0.12 Fri. March 14, 2008 ~~ updated copyright dates ~~ - upped the Moose dependency to support the custom metaclass traits - added Getopt::Long::Descriptive as an optional dependency * MooseX::Getopt MooseX::Getopt::Meta::Attribute MooseX::Getopt::Meta::Attribute::Trait MooseX::Getopt::Meta::Attribute::NoGetopt MooseX::Getopt::Meta::Attribute::Trait::NoGetopt - added support for custom metaclass traits - added tests for this 0.11 Sun. Jan. 27, 2008 * MooseX::Getopt - Commandline option shouldn't be required in the case that the given "required" attribute has a default or a builder method. 0.10 Wed. Jan. 23, 2008 * MooseX::Getopt - Support default configfile attribute when used with MooseX::ConfigFromFile-based roles 0.09 Tues. Jan. 22, 2008 * MooseX::Getopt - Use Getopt::Long::Descriptive if it's available 0.08 Tues. Dec. 8, 2007 * MooseX::Getopt - Added support for configfile loading via MooseX::ConfigFromFile-based roles with the -configfile commandline option. 0.07 Tues. Dec. 4, 2007 * MooseX::Getopt::Meta::Attribute::NoGetopt - fixed miscapitalization of NoGetopt in the docs 0.06 Fri. Nov. 23, 2007 * MooseX::Getopt - refactored &new_with_option some so that this will work better with other Getopt modules (nuffin) + MooseX::Getopt::Strict - version of MooseX::Getopt which requires you to specify which attributes you want processed explicity - added tests for this + MooseX::Getopt::Meta::Attribute::NoGetopt - a custom meta-attribute which can be used to specify that an attribute should not be processed - added tests for this 0.05 Tues. July 3, 2007 * MooseX::Getopt::OptionTypeMap - added some checks to make sure that the type constraints are found properly and to give better diagnostics 0.04 Tues. June 26, 2007 * MooseX::Getopt::OptionTypeMap - Added support for subtype constraint inference from parent types - added tests and docs for this * MooseX::Getopt - Added extra_argv attribute - added tests and docs for this - We now unmangle the Getopt::Long-mangled @ARGV - added tests and docs for this - We now throw an exception from new_with_options if Getopt fails due to bad arguments. - added tests and docs for this 0.03 Wed. May 2nd, 2007 ~ downgraded the Getopt version requirement to 2.35 as per RT #26844 ~ adding blblack to the authors list * MooseX::Getopt - doc update to show simple way to of excluding an attribute, but not having accessors with underscores (thanks to Zaba on #moose for this) * MooseX::Getopt::Meta::Attribute - tightening up the type constraint in the cmd_alias coercion to only accept strings 0.02 Friday, April 6, 2007 * MooseX::Getopt - added the ARGV attribute (thanks to blblack) - added tests and docs for this * MooseX::Getopt::Meta::Attribute - added the cmd_aliases attribute (thanks to blblack) - added tests and docs for this - added support for Moose 0.19's custom attribute metaclass alias registry. - added tests and docs for this 0.01 Friday, March 9, 2007 - module released to CPAN Makefile.PL100644000765000024 314011732225161 15221 0ustar00gfxstaff000000000000MouseX-Getopt-0.34 use strict; use warnings; use ExtUtils::MakeMaker 6.30; my %WriteMakefileArgs = ( "ABSTRACT" => "A Mouse role for processing command line options", "AUTHOR" => "NAKAGAWA Masaki , FUJI Goro , Stevan Little , Brandon L. Black , Yuval Kogman , Ryan D Johnson , Drew Taylor , Tomas Doran , Florian Ragwitz , Dagfinn Ilmari Mannsaker , Avar Arnfjord Bjarmason , Chris Prather , Mark Gardner ", "BUILD_REQUIRES" => { "Test::Exception" => "0.21", "Test::More" => "0.88", "Test::Warn" => "0.21" }, "CONFIGURE_REQUIRES" => { "ExtUtils::MakeMaker" => "6.30" }, "DISTNAME" => "MouseX-Getopt", "EXE_FILES" => [], "LICENSE" => "perl", "NAME" => "MouseX::Getopt", "PREREQ_PM" => { "Getopt::Long" => "2.37", "Getopt::Long::Descriptive" => "0.091", "Mouse" => "0.64" }, "VERSION" => "0.34", "test" => { "TESTS" => "t/*.t" } ); unless ( eval { ExtUtils::MakeMaker->VERSION(6.56) } ) { my $br = delete $WriteMakefileArgs{BUILD_REQUIRES}; my $pp = $WriteMakefileArgs{PREREQ_PM}; for my $mod ( keys %$br ) { if ( exists $pp->{$mod} ) { $pp->{$mod} = $br->{$mod} if $br->{$mod} > $pp->{$mod}; } else { $pp->{$mod} = $br->{$mod}; } } } delete $WriteMakefileArgs{CONFIGURE_REQUIRES} unless eval { ExtUtils::MakeMaker->VERSION(6.52) }; WriteMakefile(%WriteMakefileArgs); t000755000765000024 011732225161 13354 5ustar00gfxstaff000000000000MouseX-Getopt-0.34000_load.t100644000765000024 16011732225161 15154 0ustar00gfxstaff000000000000MouseX-Getopt-0.34/t#!/usr/bin/perl use strict; use warnings; use Test::More tests => 1; BEGIN { use_ok('MouseX::Getopt'); } 001_basic.t100644000765000024 1351411732225161 15366 0ustar00gfxstaff000000000000MouseX-Getopt-0.34/t#!/usr/bin/perl use strict; use warnings; use Test::More tests => 69; BEGIN { use_ok('MouseX::Getopt'); } { package App; use Mouse; with 'MouseX::Getopt'; has 'data' => ( metaclass => 'MouseX::Getopt::Meta::Attribute', is => 'ro', isa => 'Str', default => 'file.dat', cmd_flag => 'f', ); has 'cow' => ( metaclass => 'Getopt', is => 'ro', isa => 'Str', default => 'moo', cmd_aliases => [qw/ moocow m c /], ); has 'horse' => ( metaclass => 'MouseX::Getopt::Meta::Attribute', is => 'ro', isa => 'Str', default => 'bray', cmd_flag => 'horsey', cmd_aliases => 'x', ); has 'length' => ( is => 'ro', isa => 'Int', default => 24 ); has 'verbose' => ( is => 'ro', isa => 'Bool', ); has 'libs' => ( is => 'ro', isa => 'ArrayRef', default => sub { [] }, ); has 'details' => ( is => 'ro', isa => 'HashRef', default => sub { {} }, ); has '_private_stuff' => ( is => 'ro', isa => 'Int', default => 713 ); has '_private_stuff_cmdline' => ( metaclass => 'MouseX::Getopt::Meta::Attribute', is => 'ro', isa => 'Int', default => 832, cmd_flag => 'p', ); } foreach my $attr_name (qw(data cow horse _private_stuff_cmdline)) { my $attr = App->meta->get_attribute($attr_name); isa_ok($attr, 'Mouse::Meta::Attribute'); isa_ok($attr, 'MouseX::Getopt::Meta::Attribute'); can_ok($attr, 'cmd_flag'); can_ok($attr, 'cmd_aliases'); } { local @ARGV = (); my $app = App->new_with_options; isa_ok($app, 'App'); ok(!$app->verbose, '... verbosity is off as expected'); is($app->length, 24, '... length is 24 as expected'); is($app->data, 'file.dat', '... data is file.dat as expected'); is_deeply($app->libs, [], '... libs is [] as expected'); is_deeply($app->details, {}, '... details is {} as expected'); } { local @ARGV = ('--verbose', '--length', 50); my $app = App->new_with_options; isa_ok($app, 'App'); ok($app->verbose, '... verbosity is turned on as expected'); is($app->length, 50, '... length is 50 as expected'); is($app->data, 'file.dat', '... data is file.dat as expected'); is_deeply($app->libs, [], '... libs is [] as expected'); is_deeply($app->details, {}, '... details is {} as expected'); } { local @ARGV = ('--verbose', '-f', 'foo.txt'); my $app = App->new_with_options; isa_ok($app, 'App'); ok($app->verbose, '... verbosity is turned on as expected'); is($app->length, 24, '... length is 24 as expected'); is($app->data, 'foo.txt', '... data is foo.txt as expected'); is_deeply($app->libs, [], '... libs is [] as expected'); is_deeply($app->details, {}, '... details is {} as expected'); } { local @ARGV = ('--verbose', '--libs', 'libs/', '--libs', 'includes/lib'); my $app = App->new_with_options; isa_ok($app, 'App'); ok($app->verbose, '... verbosity is turned on as expected'); is($app->length, 24, '... length is 24 as expected'); is($app->data, 'file.dat', '... data is foo.txt as expected'); is_deeply($app->libs, ['libs/', 'includes/lib'], '... libs is [libs/, includes/lib] as expected'); is_deeply($app->details, {}, '... details is {} as expected'); } { local @ARGV = ('--details', 'os=mac', '--details', 'name=foo'); my $app = App->new_with_options; isa_ok($app, 'App'); ok(!$app->verbose, '... verbosity is turned on as expected'); is($app->length, 24, '... length is 24 as expected'); is($app->data, 'file.dat', '... data is foo.txt as expected'); is_deeply($app->libs, [], '... libs is [] as expected'); is_deeply($app->details, { os => 'mac', name => 'foo' }, '... details is { os => mac, name => foo } as expected'); } { # Test negation on booleans too ... local @ARGV = ('--noverbose'); my $app = App->new_with_options; isa_ok($app, 'App'); ok(!$app->verbose, '... verbosity is turned off as expected'); is($app->length, 24, '... length is 24 as expected'); is($app->data, 'file.dat', '... file is file.dat as expected'); is_deeply($app->libs, [], '... libs is [] as expected'); is_deeply($app->details, {}, '... details is {} as expected'); } # Test cmd_alias without cmd_flag { local @ARGV = ('--cow', '42'); my $app = App->new_with_options; isa_ok($app, 'App'); is($app->cow, 42, 'cmd_alias, but not using it'); } { local @ARGV = ('--moocow', '88'); my $app = App->new_with_options; isa_ok($app, 'App'); is($app->cow, 88, 'cmd_alias, using long one'); } { local @ARGV = ('-c', '99'); my $app = App->new_with_options; isa_ok($app, 'App'); is($app->cow, 99, 'cmd_alias, using short one'); } # Test cmd_alias + cmd_flag { local @ARGV = ('--horsey', '123'); my $app = App->new_with_options; isa_ok($app, 'App'); is($app->horse, 123, 'cmd_alias+cmd_flag, using flag'); } { local @ARGV = ('-x', '321'); my $app = App->new_with_options; isa_ok($app, 'App'); is($app->horse, 321, 'cmd_alias+cmd_flag, using alias'); } # Test _foo + cmd_flag { local @ARGV = ('-p', '666'); my $app = App->new_with_options; isa_ok($app, 'App'); is($app->_private_stuff_cmdline, 666, '_foo + cmd_flag'); } # Test ARGV support { my @args = ('-p', 12345, '-c', 99, '-'); local @ARGV = @args; my $app = App->new_with_options; isa_ok($app, 'App'); is_deeply($app->ARGV, \@args, 'ARGV accessor'); is_deeply(\@ARGV, \@args, '@ARGV unmangled'); is_deeply($app->extra_argv, ['-'], 'extra_argv accessor'); } 005_strict.t100644000765000024 400411732225161 15573 0ustar00gfxstaff000000000000MouseX-Getopt-0.34/t#!/usr/bin/perl use strict; use warnings; use Test::More tests => 10; use Test::Exception; BEGIN { use_ok('MouseX::Getopt'); } { package App; use Mouse; with 'MouseX::Getopt::Strict'; has 'data' => ( metaclass => 'Getopt', is => 'ro', isa => 'Str', default => 'file.dat', cmd_flag => 'f', ); has 'cow' => ( metaclass => 'Getopt', is => 'ro', isa => 'Str', default => 'moo', cmd_aliases => [qw/ moocow m c /], ); has 'horse' => ( traits => ['Getopt'], is => 'ro', isa => 'Str', default => 'bray', cmd_flag => 'horsey', cmd_aliases => 'x', ); has 'length' => ( is => 'ro', isa => 'Int', default => 24 ); has 'verbose' => ( is => 'ro', isa => 'Bool', ); has 'libs' => ( is => 'ro', isa => 'ArrayRef', default => sub { [] }, ); has 'details' => ( is => 'ro', isa => 'HashRef', default => sub { {} }, ); has 'private_stuff' => ( is => 'ro', isa => 'Int', default => 713 ); } { local @ARGV = (); my $app = App->new_with_options; isa_ok( $app, 'App' ); ok( !$app->verbose, '... verbosity is off as expected' ); is( $app->length, 24, '... length is 24 as expected' ); is( $app->data, 'file.dat', '... data is file.dat as expected' ); is_deeply( $app->libs, [], '... libs is [] as expected' ); is_deeply( $app->details, {}, '... details is {} as expected' ); is($app->private_stuff, 713, '... private stuff is 713 as expected'); } { local @ARGV = (qw/--private_stuff 317/); throws_ok { App->new_with_options } qr/Unknown option: private_stuff/; } { local @ARGV = (qw/--length 100/); throws_ok { App->new_with_options } qr/Unknown option: length/; } 010_dashes.t100644000765000024 166411732225161 15537 0ustar00gfxstaff000000000000MouseX-Getopt-0.34/t#!/usr/bin/perl use strict; use warnings; use Test::More tests => 5; use Test::Exception; BEGIN { use_ok('MouseX::Getopt'); } { package App; use Mouse; with 'MouseX::Getopt::Dashes'; has 'some_thingy' => ( is => 'ro', isa => 'Str', default => 'foo' ); has 'another_thingy' => ( is => 'ro', isa => 'Str', default => 'foo', cmd_flag => 'another_thingy', traits => [ 'Getopt' ], ); } { local @ARGV = (qw/--some-thingy bar/); lives_and { is( App->new_with_options->some_thingy, 'bar') } 'Dash in option name'; } { local @ARGV = (qw/--some_thingy bar/); throws_ok { App->new_with_options } qr/Unknown option: some_thingy/; } { local @ARGV = (qw/--another_thingy bar/); lives_and { is( App->new_with_options->another_thingy, 'bar' ) } 'Underscore in option name'; } { local @ARGV = (qw/--another-thingy bar/); throws_ok { App->new_with_options } qr/Unknown option: another-thingy/; } 103_uc_bug.t100644000765000024 113011732225161 15523 0ustar00gfxstaff000000000000MouseX-Getopt-0.34/t#!/usr/bin/perl use strict; use warnings; use Test::More tests => 3; { package App; use Mouse; with qw(MouseX::Getopt); has 'TrackingNumber' => ( is => 'rw', isa => 'Str', ); has 'otherparam' => ( is => 'rw', isa => 'Str', ); } { local @ARGV = ('--TrackingNumber','1Z1234567812345670','--otherparam','foo'); my $app = App->new_with_options; isa_ok($app, 'App'); is($app->TrackingNumber, '1Z1234567812345670', '... TrackingNumber is as expected'); is($app->otherparam, 'foo', '... otherparam is as expected'); } 004_nogetop.t100644000765000024 414111732225161 15737 0ustar00gfxstaff000000000000MouseX-Getopt-0.34/t#!/usr/bin/perl use strict; use warnings; use Test::More tests => 9; use Test::Exception; BEGIN { use_ok('MouseX::Getopt'); } { package App; use Mouse; with 'MouseX::Getopt'; has 'data' => ( metaclass => 'Getopt', is => 'ro', isa => 'Str', default => 'file.dat', cmd_flag => 'f', ); has 'cow' => ( metaclass => 'Getopt', is => 'ro', isa => 'Str', default => 'moo', cmd_aliases => [qw/ moocow m c /], ); has 'horse' => ( metaclass => 'Getopt', is => 'ro', isa => 'Str', default => 'bray', cmd_flag => 'horsey', cmd_aliases => 'x', ); has 'length' => ( is => 'ro', isa => 'Int', default => 24 ); has 'verbose' => ( is => 'ro', isa => 'Bool', ); has 'libs' => ( is => 'ro', isa => 'ArrayRef', default => sub { [] }, ); has 'details' => ( is => 'ro', isa => 'HashRef', default => sub { {} }, ); has 'private_stuff' => ( metaclass => 'NoGetopt', is => 'ro', isa => 'Int', default => 713 ); has '_private_stuff_cmdline' => ( metaclass => 'Getopt', is => 'ro', isa => 'Int', default => 832, cmd_flag => 'p', ); } { local @ARGV = (); my $app = App->new_with_options; isa_ok( $app, 'App' ); ok( !$app->verbose, '... verbosity is off as expected' ); is( $app->length, 24, '... length is 24 as expected' ); is( $app->data, 'file.dat', '... data is file.dat as expected' ); is_deeply( $app->libs, [], '... libs is [] as expected' ); is_deeply( $app->details, {}, '... details is {} as expected' ); is($app->private_stuff, 713, '... private stuff is 713 as expected'); } { local @ARGV = (qw/--private_stuff 317/); throws_ok { App->new_with_options } qr/Unknown option: private_stuff/; } release-eol.t100644000765000024 47611732225161 16065 0ustar00gfxstaff000000000000MouseX-Getopt-0.34/t BEGIN { unless ($ENV{RELEASE_TESTING}) { require Test::More; Test::More::plan(skip_all => 'these tests are for release candidate testing'); } } use strict; use warnings; use Test::More; eval 'use Test::EOL'; plan skip_all => 'Test::EOL required' if $@; all_perl_files_ok({ trailing_whitespace => 1 }); 101_argv_bug.t100644000765000024 114711732225161 16061 0ustar00gfxstaff000000000000MouseX-Getopt-0.34/t#!/usr/bin/env perl use strict; use warnings; use Test::More tests => 3; use MouseX::Getopt; { package App; use Mouse; with 'MouseX::Getopt'; has 'length' => ( is => 'ro', isa => 'Int', default => 24, ); has 'verbose' => ( is => 'ro', isa => 'Bool', default => 0, ); no Mouse; } { my $app = App->new_with_options(argv => [ '--verbose', '--length', 50 ]); isa_ok($app, 'App'); ok($app->verbose, '... verbosity is turned on as expected'); is($app->length, 50, '... length is 50 as expected'); } 109_help_flag.t100644000765000024 330511732225161 16214 0ustar00gfxstaff000000000000MouseX-Getopt-0.34/t#!/usr/bin/env perl # The documentation claims: # If Getopt::Long::Descriptive is installed and any of the following command # line params are passed (--help, --usage, --?), the program will exit with # usage information... # This is not actually true (as of 0.29), as: # 1. the consuming class must set up a attributes named 'help', 'usage' and # '?' to contain these command line options, which is not clearly # documented as a requirement # 2. the code is checking whether an option was parsed into an attribute # *called* 'help', 'usage' or '?', not whether the option --help, --usage # or --? was passed on the command-line (the mapping could be different, # if cmd_flag or cmd_aliases is used), # This inconsistency is the underlying cause of RT#52474, RT#57683, RT#47865. use strict; use warnings; use Test::More tests => 6; use Test::Exception; { package MyClass; use strict; use warnings; use Mouse; with 'MouseX::Getopt'; } # before fix, prints this on stderr: #Unknown option: ? #usage: test1.t # after fix, prints this on stderr: #usage: test1.t [-?] [long options...] # -? --usage --help Prints this usage information. foreach my $args ( ['--help'], ['--usage'], ['--?'], ['-?'] ) { local @ARGV = @$args; throws_ok { MyClass->new_with_options() } qr/^usage: (?:[\d\w]+)\Q.t [-?] [long options...]\E.^\t\Q-? --usage --help Prints this usage information.\E$/ms, 'Help request detected; usage information properly printed'; } # now call again, and ensure we got the usage info. my $obj = MyClass->new_with_options(); ok($obj->meta->has_attribute('usage'), 'class has usage attribute'); isa_ok($obj->usage, 'Getopt::Long::Descriptive::Usage'); 108_usage_attr.t100644000765000024 165111732225161 16432 0ustar00gfxstaff000000000000MouseX-Getopt-0.34/t#!/usr/bin/env perl # Re RT#58715 and the claim in the documentation: # If you have Getopt::Long::Descriptive the usage param is also passed to new. # This tests the fix (that fulfills the documentation claim). use strict; use warnings; use Test::More tests => 3; { package MyClass; use strict; use warnings; use Mouse; with 'MouseX::Getopt'; } Mouse::Meta::Class->create('MyClassWithBasic', superclasses => ['MyClass'], roles => [ 'MouseX::Getopt::Basic' ], ); my $basic_obj = MyClassWithBasic->new_with_options(); ok(!$basic_obj->meta->has_attribute('usage'), 'basic class has no usage attribute'); Mouse::Meta::Class->create('MyClassWithGLD', superclasses => ['MyClass'], roles => [ 'MouseX::Getopt' ], ); my $gld_obj = MyClassWithGLD->new_with_options(); ok($gld_obj->meta->has_attribute('usage'), 'class has usage attribute'); isa_ok($gld_obj->usage, 'Getopt::Long::Descriptive::Usage'); 102_basic_basic.t100644000765000024 1353211732225161 16531 0ustar00gfxstaff000000000000MouseX-Getopt-0.34/t#!/usr/bin/perl use strict; use warnings; use Test::More tests => 69; BEGIN { use_ok('MouseX::Getopt::Basic'); } { package App; use Mouse; with 'MouseX::Getopt::Basic'; has 'data' => ( metaclass => 'MouseX::Getopt::Meta::Attribute', is => 'ro', isa => 'Str', default => 'file.dat', cmd_flag => 'f', ); has 'cow' => ( metaclass => 'Getopt', is => 'ro', isa => 'Str', default => 'moo', cmd_aliases => [qw/ moocow m c /], ); has 'horse' => ( metaclass => 'MouseX::Getopt::Meta::Attribute', is => 'ro', isa => 'Str', default => 'bray', cmd_flag => 'horsey', cmd_aliases => 'x', ); has 'length' => ( is => 'ro', isa => 'Int', default => 24 ); has 'verbose' => ( is => 'ro', isa => 'Bool', ); has 'libs' => ( is => 'ro', isa => 'ArrayRef', default => sub { [] }, ); has 'details' => ( is => 'ro', isa => 'HashRef', default => sub { {} }, ); has '_private_stuff' => ( is => 'ro', isa => 'Int', default => 713 ); has '_private_stuff_cmdline' => ( metaclass => 'MouseX::Getopt::Meta::Attribute', is => 'ro', isa => 'Int', default => 832, cmd_flag => 'p', ); } foreach my $attr_name (qw(data cow horse _private_stuff_cmdline)) { my $attr = App->meta->get_attribute($attr_name); isa_ok($attr, 'Mouse::Meta::Attribute'); isa_ok($attr, 'MouseX::Getopt::Meta::Attribute'); can_ok($attr, 'cmd_flag'); can_ok($attr, 'cmd_aliases'); } { local @ARGV = (); my $app = App->new_with_options; isa_ok($app, 'App'); ok(!$app->verbose, '... verbosity is off as expected'); is($app->length, 24, '... length is 24 as expected'); is($app->data, 'file.dat', '... data is file.dat as expected'); is_deeply($app->libs, [], '... libs is [] as expected'); is_deeply($app->details, {}, '... details is {} as expected'); } { local @ARGV = ('--verbose', '--length', 50); my $app = App->new_with_options; isa_ok($app, 'App'); ok($app->verbose, '... verbosity is turned on as expected'); is($app->length, 50, '... length is 50 as expected'); is($app->data, 'file.dat', '... data is file.dat as expected'); is_deeply($app->libs, [], '... libs is [] as expected'); is_deeply($app->details, {}, '... details is {} as expected'); } { local @ARGV = ('--verbose', '-f', 'foo.txt'); my $app = App->new_with_options; isa_ok($app, 'App'); ok($app->verbose, '... verbosity is turned on as expected'); is($app->length, 24, '... length is 24 as expected'); is($app->data, 'foo.txt', '... data is foo.txt as expected'); is_deeply($app->libs, [], '... libs is [] as expected'); is_deeply($app->details, {}, '... details is {} as expected'); } { local @ARGV = ('--verbose', '--libs', 'libs/', '--libs', 'includes/lib'); my $app = App->new_with_options; isa_ok($app, 'App'); ok($app->verbose, '... verbosity is turned on as expected'); is($app->length, 24, '... length is 24 as expected'); is($app->data, 'file.dat', '... data is foo.txt as expected'); is_deeply($app->libs, ['libs/', 'includes/lib'], '... libs is [libs/, includes/lib] as expected'); is_deeply($app->details, {}, '... details is {} as expected'); } { local @ARGV = ('--details', 'os=mac', '--details', 'name=foo'); my $app = App->new_with_options; isa_ok($app, 'App'); ok(!$app->verbose, '... verbosity is turned on as expected'); is($app->length, 24, '... length is 24 as expected'); is($app->data, 'file.dat', '... data is foo.txt as expected'); is_deeply($app->libs, [], '... libs is [] as expected'); is_deeply($app->details, { os => 'mac', name => 'foo' }, '... details is { os => mac, name => foo } as expected'); } { # Test negation on booleans too ... local @ARGV = ('--noverbose'); my $app = App->new_with_options; isa_ok($app, 'App'); ok(!$app->verbose, '... verbosity is turned off as expected'); is($app->length, 24, '... length is 24 as expected'); is($app->data, 'file.dat', '... file is file.dat as expected'); is_deeply($app->libs, [], '... libs is [] as expected'); is_deeply($app->details, {}, '... details is {} as expected'); } # Test cmd_alias without cmd_flag { local @ARGV = ('--cow', '42'); my $app = App->new_with_options; isa_ok($app, 'App'); is($app->cow, 42, 'cmd_alias, but not using it'); } { local @ARGV = ('--moocow', '88'); my $app = App->new_with_options; isa_ok($app, 'App'); is($app->cow, 88, 'cmd_alias, using long one'); } { local @ARGV = ('-c', '99'); my $app = App->new_with_options; isa_ok($app, 'App'); is($app->cow, 99, 'cmd_alias, using short one'); } # Test cmd_alias + cmd_flag { local @ARGV = ('--horsey', '123'); my $app = App->new_with_options; isa_ok($app, 'App'); is($app->horse, 123, 'cmd_alias+cmd_flag, using flag'); } { local @ARGV = ('-x', '321'); my $app = App->new_with_options; isa_ok($app, 'App'); is($app->horse, 321, 'cmd_alias+cmd_flag, using alias'); } # Test _foo + cmd_flag { local @ARGV = ('-p', '666'); my $app = App->new_with_options; isa_ok($app, 'App'); is($app->_private_stuff_cmdline, 666, '_foo + cmd_flag'); } # Test ARGV support { my @args = ('-p', 12345, '-c', 99, '-'); local @ARGV = @args; my $app = App->new_with_options; isa_ok($app, 'App'); is_deeply($app->ARGV, \@args, 'ARGV accessor'); is_deeply(\@ARGV, \@args, '@ARGV unmangled'); is_deeply($app->extra_argv, ['-'], 'extra_argv accessor'); } 105_uc_bug_more.t100644000765000024 172511732225161 16561 0ustar00gfxstaff000000000000MouseX-Getopt-0.34/tuse strict; use warnings; use Test::More; use Mouse (); use Mouse::Meta::Class; foreach my $role (qw/ MouseX::Getopt MouseX::Getopt::GLD MouseX::Getopt::Basic /) { Mouse::Util::load_class($role); my $meta = Mouse::Meta::Class->create_anon_class( superclasses => ['Mouse::Object'], ); $meta->add_attribute('Debug', traits => ['Getopt'], isa => 'Bool', cmd_aliases => ['d'], is => 'ro'); $role->meta->apply($meta); ok($meta->name->new_with_options({ argv => ['-d'] })->Debug, "Debug was set for argv -d on $role"); { local @ARGV = ('-d'); ok($meta->name->new_with_options()->Debug, "Debug was set for ARGV on $role"); } ok($meta->name->new_with_options({ argv => ['--Debug'] })->Debug, "Debug was set for argv --Debug on $role"); ok($meta->name->new_with_options({ argv => ['--debug'] })->Debug, "Debug was set for argv --debug on $role"); } done_testing; release-no-tabs.t100644000765000024 45011732225161 16641 0ustar00gfxstaff000000000000MouseX-Getopt-0.34/t BEGIN { unless ($ENV{RELEASE_TESTING}) { require Test::More; Test::More::plan(skip_all => 'these tests are for release candidate testing'); } } use strict; use warnings; use Test::More; eval 'use Test::NoTabs'; plan skip_all => 'Test::NoTabs required' if $@; all_perl_files_ok(); MouseX000755000765000024 011732225161 15077 5ustar00gfxstaff000000000000MouseX-Getopt-0.34/libGetopt.pm100644000765000024 1773611732225161 17075 0ustar00gfxstaff000000000000MouseX-Getopt-0.34/lib/MouseXpackage MouseX::Getopt; BEGIN { $MouseX::Getopt::AUTHORITY = 'cpan:STEVAN'; } { $MouseX::Getopt::VERSION = '0.34'; } # ABSTRACT: A Mouse role for processing command line options use Mouse::Role; with 'MouseX::Getopt::GLD'; no Mouse::Role; 1; __END__ =pod =encoding utf-8 =head1 NAME MouseX::Getopt - A Mouse role for processing command line options =head1 SYNOPSIS ## In your class package My::App; use Mouse; with 'MouseX::Getopt'; has 'out' => (is => 'rw', isa => 'Str', required => 1); has 'in' => (is => 'rw', isa => 'Str', required => 1); # ... rest of the class here ## in your script #!/usr/bin/perl use My::App; my $app = My::App->new_with_options(); # ... rest of the script here ## on the command line % perl my_app_script.pl -in file.input -out file.dump =head1 DESCRIPTION This is a role which provides an alternate constructor for creating objects using parameters passed in from the command line. This module attempts to DWIM as much as possible with the command line params by introspecting your class's attributes. It will use the name of your attribute as the command line option, and if there is a type constraint defined, it will configure Getopt::Long to handle the option accordingly. You can use the trait L or the attribute metaclass L to get non-default commandline option names and aliases. You can use the trait L or the attribute metaclass L to have C ignore your attribute in the commandline options. By default, attributes which start with an underscore are not given commandline argument support, unless the attribute's metaclass is set to L. If you don't want your accessors to have the leading underscore in their name, you can do this: # for read/write attributes has '_foo' => (accessor => 'foo', ...); # or for read-only attributes has '_bar' => (reader => 'bar', ...); This will mean that Getopt will not handle a --foo param, but your code can still call the C method. If your class also uses a configfile-loading role based on L, such as L, L's C will load the configfile specified by the C<--configfile> option (or the default you've given for the configfile attribute) for you. Options specified in multiple places follow the following precendence order: commandline overrides configfile, which overrides explicit new_with_options parameters. =head2 Supported Type Constraints =over 4 =item I A I type constraint is set up as a boolean option with Getopt::Long. So that this attribute description: has 'verbose' => (is => 'rw', isa => 'Bool'); would translate into C as a Getopt::Long option descriptor, which would enable the following command line options: % my_script.pl --verbose % my_script.pl --noverbose =item I, I, I These type constraints are set up as properly typed options with Getopt::Long, using the C<=i>, C<=f> and C<=s> modifiers as appropriate. =item I An I type constraint is set up as a multiple value option in Getopt::Long. So that this attribute description: has 'include' => ( is => 'rw', isa => 'ArrayRef', default => sub { [] } ); would translate into C as a Getopt::Long option descriptor, which would enable the following command line options: % my_script.pl --include /usr/lib --include /usr/local/lib =item I A I type constraint is set up as a hash value option in Getopt::Long. So that this attribute description: has 'define' => ( is => 'rw', isa => 'HashRef', default => sub { {} } ); would translate into C as a Getopt::Long option descriptor, which would enable the following command line options: % my_script.pl --define os=linux --define vendor=debian =back =head2 Custom Type Constraints It is possible to create custom type constraint to option spec mappings if you need them. The process is fairly simple (but a little verbose maybe). First you create a custom subtype, like so: subtype 'ArrayOfInts' => as 'ArrayRef' => where { scalar (grep { looks_like_number($_) } @$_) }; Then you register the mapping, like so: MouseX::Getopt::OptionTypeMap->add_option_type_to_map( 'ArrayOfInts' => '=i@' ); Now any attribute declarations using this type constraint will get the custom option spec. So that, this: has 'nums' => ( is => 'ro', isa => 'ArrayOfInts', default => sub { [0] } ); Will translate to the following on the command line: % my_script.pl --nums 5 --nums 88 --nums 199 This example is fairly trivial, but more complex validations are easily possible with a little creativity. The trick is balancing the type constraint validations with the Getopt::Long validations. Better examples are certainly welcome :) =head2 Inferred Type Constraints If you define a custom subtype which is a subtype of one of the standard L above, and do not explicitly provide custom support as in L above, MouseX::Getopt will treat it like the parent type for Getopt purposes. For example, if you had the same custom C subtype from the examples above, but did not add a new custom option type for it to the C, it would be treated just like a normal C type for Getopt purposes (that is, C<=s@>). =head1 METHODS =head2 B This method will take a set of default C<%params> and then collect params from the command line (possibly overriding those in C<%params>) and then return a newly constructed object. The special parameter C, if specified should point to an array reference with an array to use instead of C<@ARGV>. If L fails (due to invalid arguments), C will throw an exception. If L is installed and any of the following command line params are passed, the program will exit with usage information (and the option's state will be stored in the help_flag attribute). You can add descriptions for each option by including a B option for each attribute to document. --? --help --usage If you have L the C param is also passed to C as the usage option. =head2 B This accessor contains a reference to a copy of the C<@ARGV> array as it originally existed at the time of C. =head2 B This accessor contains an arrayref of leftover C<@ARGV> elements that L did not parse. Note that the real C<@ARGV> is left un-mangled. =head2 B This accessor contains the L object (if L is used). =head2 B This accessor contains the boolean state of the --help, --usage and --? options (true if any of these options were passed on the command line). =head2 B This returns the role meta object. =head1 AUTHORS =over 4 =item * NAKAGAWA Masaki =item * FUJI Goro =item * Stevan Little =item * Brandon L. Black =item * Yuval Kogman =item * Ryan D Johnson =item * Drew Taylor =item * Tomas Doran =item * Florian Ragwitz =item * Dagfinn Ilmari Mannsaker =item * Avar Arnfjord Bjarmason =item * Chris Prather =item * Mark Gardner =back =head1 COPYRIGHT AND LICENSE This software is copyright (c) 2012 by Infinity Interactive, Inc. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. =cut 107_no_auto_help.t100644000765000024 354311732225161 16751 0ustar00gfxstaff000000000000MouseX-Getopt-0.34/t# Related information: # https://rt.cpan.org/Public/Bug/Display.html?id=47865 # https://rt.cpan.org/Public/Bug/Display.html?id=52474 # https://rt.cpan.org/Public/Bug/Display.html?id=57683 # http://www.nntp.perl.org/group/perl.moose/2010/06/msg1767.html # Summary: If we disable the "auto_help" option in Getopt::Long, then # getoptions() will not call into pod2usage() (causing program termination) # when --help is passed (and MouseX::ConfigFromFile is in use). use strict; use warnings; use Test::More; BEGIN { plan skip_all => 'This test needs MouseX::SimpleConfig 0.07' unless eval { require MouseX::SimpleConfig && MouseX::SimpleConfig->VERSION(0.07); }; } my $fail_on_exit = 1; { package Class; use strict; use warnings; use Mouse; with 'MouseX::SimpleConfig', 'MouseX::Getopt'; # this is a hacky way of being able to check that we made it past the # $opt_parser->getoptions() call in new_with_options, because it is # still going to bail out later on, on seeing the --help flag has configfile => ( is => 'ro', isa => 'Str', default => sub { $fail_on_exit = 0; 'this_value_unimportant', }, ); no Mouse; 1; } use Test::Warn; use Test::Exception; END { ok(!$fail_on_exit, 'getoptions() lives'); done_testing; # cancel the non-zero exit status from _getopt_full_usage() exit 0; } @ARGV = ('--help'); warning_like { throws_ok { Class->new_with_options } #usage: 107_no_auto_help.t [-?] [long options...] qr/^usage: [\d\w]+\Q.t [-?] [long options...]\E.\s+\Q-? --usage --help Prints this usage information.\E.\s+--configfile/ms, 'usage information looks good'; } qr/^Specified configfile \'this_value_unimportant\' does not exist, is empty, or is not readable$/, 'Our dummy config file doesn\'t exist'; 007_nogetopt_trait.t100644000765000024 415211732225161 17333 0ustar00gfxstaff000000000000MouseX-Getopt-0.34/t#!/usr/bin/perl use strict; use warnings; use Test::More tests => 9; use Test::Exception; BEGIN { use_ok('MouseX::Getopt'); } { package App; use Mouse; with 'MouseX::Getopt'; has 'data' => ( traits => ['Getopt'], is => 'ro', isa => 'Str', default => 'file.dat', cmd_flag => 'f', ); has 'cow' => ( traits => ['Getopt'], is => 'ro', isa => 'Str', default => 'moo', cmd_aliases => [qw/ moocow m c /], ); has 'horse' => ( traits => ['Getopt'], is => 'ro', isa => 'Str', default => 'bray', cmd_flag => 'horsey', cmd_aliases => 'x', ); has 'length' => ( is => 'ro', isa => 'Int', default => 24 ); has 'verbose' => ( is => 'ro', isa => 'Bool', ); has 'libs' => ( is => 'ro', isa => 'ArrayRef', default => sub { [] }, ); has 'details' => ( is => 'ro', isa => 'HashRef', default => sub { {} }, ); has 'private_stuff' => ( traits => ['NoGetopt'], is => 'ro', isa => 'Int', default => 713 ); has '_private_stuff_cmdline' => ( traits => ['Getopt'], is => 'ro', isa => 'Int', default => 832, cmd_flag => 'p', ); } { local @ARGV = (); my $app = App->new_with_options; isa_ok( $app, 'App' ); ok( !$app->verbose, '... verbosity is off as expected' ); is( $app->length, 24, '... length is 24 as expected' ); is( $app->data, 'file.dat', '... data is file.dat as expected' ); is_deeply( $app->libs, [], '... libs is [] as expected' ); is_deeply( $app->details, {}, '... details is {} as expected' ); is($app->private_stuff, 713, '... private stuff is 713 as expected'); } { local @ARGV = (qw/--private_stuff 317/); throws_ok { App->new_with_options } qr/Unknown option: private_stuff/; } 008_configfromfile.t100644000765000024 1244411732225161 17306 0ustar00gfxstaff000000000000MouseX-Getopt-0.34/t#!/usr/bin/env perl use strict; use warnings; use Test::Exception; use Test::More; use File::Spec; if ( !eval { require MouseX::ConfigFromFile } ) { plan skip_all => 'Test requires MouseX::ConfigFromFile'; } else { plan tests => 37; } { package App; use Mouse; with 'MouseX::Getopt'; with 'MouseX::ConfigFromFile'; has 'config_from_override' => ( is => 'ro', isa => 'Bool', default => 0, ); has 'optional_from_config' => ( is => 'ro', isa => 'Str', required => 0, ); has 'required_from_config' => ( is => 'ro', isa => 'Str', required => 1, ); has 'required_from_argv' => ( is => 'ro', isa => 'Str', required => 1, ); sub get_config_from_file { my ( $class, $file ) = @_; my %config = ( required_from_config => 'from_config_1', optional_from_config => 'from_config_2', ); my $cpath = File::Spec->canonpath('/notused/default'); if ( $file ne $cpath ) { $config{config_from_override} = 1; } return \%config; } } { package App::DefaultConfigFile; use Mouse; extends 'App'; has '+configfile' => ( default => File::Spec->canonpath('/notused/default'), ); } { package App::DefaultConfigFileCodeRef; use Mouse; extends 'App'; has '+configfile' => ( default => sub { return File::Spec->canonpath('/notused/default') }, ); } # No config specified { local @ARGV = qw( --required_from_argv 1 ); throws_ok { App->new_with_options } qr/Mandatory parameter 'required_from_config' missing/; { my $app = App::DefaultConfigFile->new_with_options; isa_ok( $app, 'App::DefaultConfigFile' ); app_ok( $app ); ok( !$app->config_from_override, '... config_from_override false as expected' ); is( $app->configfile, File::Spec->canonpath('/notused/default'), '... configfile is /notused/default as expected' ); } } # No config specified { local @ARGV = qw( --required_from_argv 1 ); { my $app = App::DefaultConfigFileCodeRef->new_with_options; isa_ok( $app, 'App::DefaultConfigFileCodeRef' ); app_ok( $app ); ok( !$app->config_from_override, '... config_from_override false as expected' ); is( $app->configfile, File::Spec->canonpath('/notused/default'), '... configfile is /notused/default as expected' ); } } # Config specified { local @ARGV = qw( --configfile /notused --required_from_argv 1 ); { my $app = App->new_with_options; isa_ok( $app, 'App' ); app_ok( $app ); } { my $app = App::DefaultConfigFile->new_with_options; isa_ok( $app, 'App::DefaultConfigFile' ); app_ok( $app ); ok( $app->config_from_override, '... config_from_override true as expected' ); is( $app->configfile, File::Spec->canonpath('/notused'), '... configfile is /notused as expected' ); } { my $app = App::DefaultConfigFileCodeRef->new_with_options; isa_ok( $app, 'App::DefaultConfigFileCodeRef' ); app_ok( $app ); ok( $app->config_from_override, '... config_from_override true as expected' ); is( $app->configfile, File::Spec->canonpath('/notused'), '... configfile is /notused as expected' ); } } # Required arg not supplied from cmdline { local @ARGV = qw( --configfile /notused ); throws_ok { App->new_with_options } qr/Mandatory parameter 'required_from_argv' missing/; } # Config file value overriden from cmdline { local @ARGV = qw( --configfile /notused --required_from_argv 1 --required_from_config override ); my $app = App->new_with_options; isa_ok( $app, 'App' ); is( $app->required_from_config, 'override', '... required_from_config is override as expected' ); is( $app->optional_from_config, 'from_config_2', '... optional_from_config is from_config_2 as expected' ); } # No config file { local @ARGV = qw( --required_from_argv 1 --required_from_config noconfig ); my $app = App->new_with_options; isa_ok( $app, 'App' ); is( $app->required_from_config, 'noconfig', '... required_from_config is noconfig as expected' ); ok( !defined $app->optional_from_config, '... optional_from_config is undef as expected' ); } { package BaseApp::WithConfig; use Mouse; with 'MouseX::ConfigFromFile'; sub get_config_from_file { return {}; } } { package DerivedApp::Getopt; use Mouse; extends 'BaseApp::WithConfig'; with 'MouseX::Getopt'; } # With DerivedApp, the Getopt role was applied at a different level # than the ConfigFromFile role { lives_ok { DerivedApp::Getopt->new_with_options } 'Can create DerivedApp'; } sub app_ok { my $app = shift; is( $app->required_from_config, 'from_config_1', '... required_from_config is from_config_1 as expected' ); is( $app->optional_from_config, 'from_config_2', '... optional_from_config is from_config_2 as expected' ); is( $app->required_from_argv, '1', '... required_from_argv is 1 as expected' ); } 104_override_usage.t100644000765000024 263111732225161 17272 0ustar00gfxstaff000000000000MouseX-Getopt-0.34/tuse strict; use warnings; use Test::More 0.88; use Test::Exception; { package MyScript; use Mouse; with 'MouseX::Getopt'; has foo => ( isa => 'Int', is => 'ro', documentation => 'A foo' ); our $usage = 0; before _getopt_full_usage => sub { $usage++; }; our @warnings; before _getopt_spec_warnings => sub { shift; push(@warnings, @_) }; our @exception; before _getopt_spec_exception => sub { shift; push(@exception, @{ shift() }, shift()) }; } { local $MyScript::usage; local @MyScript::warnings; local @MyScript::exception; local @ARGV = ('--foo', '1'); my $i = MyScript->new_with_options; ok $i; is $i->foo, 1; is $MyScript::usage, undef; } { local $MyScript::usage; local @MyScript::warnings; local @MyScript::exception; local @ARGV = ('--help'); throws_ok { MyScript->new_with_options } qr/A foo/; is $MyScript::usage, 1; } { local $MyScript::usage; local @MyScript::warnings; local @MyScript::exception; local @ARGV = ('-q'); # Does not exist throws_ok { MyScript->new_with_options } qr/A foo/; is_deeply \@MyScript::warnings, [ 'Unknown option: q ' ]; my $exp = [ 'Unknown option: q ', qq{usage: 104_override_usage.t [-?] [long options...] \t-? --usage --help Prints this usage information. \t--foo A foo } ]; is_deeply \@MyScript::exception, $exp; } done_testing; 106_no_ignore_case.t100644000765000024 304111732225161 17237 0ustar00gfxstaff000000000000MouseX-Getopt-0.34/tuse strict; use warnings; use Test::More; use Mouse (); use Mouse::Meta::Class; foreach my $role (qw/ MouseX::Getopt MouseX::Getopt::GLD MouseX::Getopt::Basic /) { Mouse::Util::load_class($role); my $meta = Mouse::Meta::Class->create_anon_class( superclasses => ['Mouse::Object'], ); $meta->add_attribute('BigD', traits => ['Getopt'], isa => 'Bool', cmd_aliases => ['D'], is => 'ro'); $meta->add_attribute('SmallD', traits => ['Getopt'], isa => 'Bool', cmd_aliases => ['d'], is => 'ro'); $role->meta->apply($meta); { my $obj = $meta->name->new_with_options( { argv => ["-d"], no_ignore_case => 1} ); ok((! $obj->BigD), "BigD was not set for argv -d on $role"); ok($obj->SmallD, "SmallD was set for argv -d on $role"); } ok($meta->name->new_with_options({ argv => ['-d'], no_ignore_case => 1}) ->SmallD, "SmallD was set for argv -d on $role"); { local @ARGV = ('-d'); ok($meta->name->new_with_options()->SmallD, "SmallD was set for ARGV on $role"); } ok($meta->name->new_with_options({ argv => ['-D'], no_ignore_case => 1}) ->BigD, "BigD was set for argv -d on $role"); { my $obj = $meta->name->new_with_options( { argv => ['-D', "-d"], no_ignore_case => 1} ); ok($obj->BigD, "BigD was set for argv -D -d on $role"); ok($obj->SmallD, "SmallD was set for argv -D -d on $role"); } } done_testing; release-pod-syntax.t100644000765000024 45011732225161 17404 0ustar00gfxstaff000000000000MouseX-Getopt-0.34/t#!perl BEGIN { unless ($ENV{RELEASE_TESTING}) { require Test::More; Test::More::plan(skip_all => 'these tests are for release candidate testing'); } } use Test::More; eval "use Test::Pod 1.41"; plan skip_all => "Test::Pod 1.41 required for testing POD" if $@; all_pod_files_ok(); 100_gld_default_bug.t100644000765000024 157511732225161 17400 0ustar00gfxstaff000000000000MouseX-Getopt-0.34/t#!/usr/bin/perl use strict; use warnings; use Test::More; use Test::Exception; BEGIN { eval 'use Getopt::Long::Descriptive;'; plan skip_all => "Getopt::Long::Descriptive required for this test" if $@; plan tests => 5; use_ok('MouseX::Getopt'); } { package Engine::Foo; use Mouse; with 'MouseX::Getopt'; has 'nproc' => ( metaclass => 'Getopt', is => 'ro', isa => 'Int', default => sub { 1 }, cmd_aliases => 'n', ); } @ARGV = (); { my $foo = Engine::Foo->new_with_options(nproc => 10); isa_ok($foo, 'Engine::Foo'); is($foo->nproc, 10, '... got the right value (10), not the default (1)'); } { my $foo = Engine::Foo->new_with_options(); isa_ok($foo, 'Engine::Foo'); is($foo->nproc, 1, '... got the right value (1), without GLD needing to handle defaults'); } Getopt000755000765000024 011732225161 16341 5ustar00gfxstaff000000000000MouseX-Getopt-0.34/lib/MouseXGLD.pm100644000765000024 665411732225161 17460 0ustar00gfxstaff000000000000MouseX-Getopt-0.34/lib/MouseX/Getoptpackage MouseX::Getopt::GLD; BEGIN { $MouseX::Getopt::GLD::AUTHORITY = 'cpan:STEVAN'; } { $MouseX::Getopt::GLD::VERSION = '0.34'; } # ABSTRACT: A Mouse role for processing command line options with Getopt::Long::Descriptive use Mouse::Role; use Getopt::Long::Descriptive 0.081; with 'MouseX::Getopt::Basic'; has usage => ( is => 'rw', isa => 'Getopt::Long::Descriptive::Usage', traits => ['NoGetopt'], ); # captures the options: --help --usage --? has help_flag => ( is => 'ro', isa => 'Bool', traits => ['Getopt'], cmd_flag => 'help', cmd_aliases => [ qw(usage ?) ], documentation => 'Prints this usage information.', ); around _getopt_spec => sub { shift; shift->_gld_spec(@_); }; around _getopt_get_options => sub { shift; my ($class, $params, $opt_spec) = @_; return Getopt::Long::Descriptive::describe_options($class->_usage_format(%$params), @$opt_spec); }; sub _gld_spec { my ( $class, %params ) = @_; my ( @options, %name_to_init_arg ); my $constructor_params = $params{params}; foreach my $opt ( @{ $params{options} } ) { push @options, [ $opt->{opt_string}, $opt->{doc} || ' ', # FIXME new GLD shouldn't need this hack { ( ( $opt->{required} && !exists($constructor_params->{$opt->{init_arg}}) ) ? (required => $opt->{required}) : () ), # NOTE: # remove this 'feature' because it didn't work # all the time, and so is better to not bother # since Mouse will handle the defaults just # fine anyway. # - SL #( exists $opt->{default} ? (default => $opt->{default}) : () ), }, ]; my $identifier = lc($opt->{name}); $identifier =~ s/\W/_/g; # Getopt::Long does this to all option names $name_to_init_arg{$identifier} = $opt->{init_arg}; } return ( \@options, \%name_to_init_arg ); } no Mouse::Role; 1; __END__ =pod =encoding utf-8 =head1 NAME MouseX::Getopt::GLD - A Mouse role for processing command line options with Getopt::Long::Descriptive =head1 SYNOPSIS ## In your class package My::App; use Mouse; with 'MouseX::Getopt::GLD'; has 'out' => (is => 'rw', isa => 'Str', required => 1); has 'in' => (is => 'rw', isa => 'Str', required => 1); # ... rest of the class here ## in your script #!/usr/bin/perl use My::App; my $app = My::App->new_with_options(); # ... rest of the script here ## on the command line % perl my_app_script.pl -in file.input -out file.dump =head1 AUTHORS =over 4 =item * NAKAGAWA Masaki =item * FUJI Goro =item * Stevan Little =item * Brandon L. Black =item * Yuval Kogman =item * Ryan D Johnson =item * Drew Taylor =item * Tomas Doran =item * Florian Ragwitz =item * Dagfinn Ilmari Mannsaker =item * Avar Arnfjord Bjarmason =item * Chris Prather =item * Mark Gardner =back =head1 COPYRIGHT AND LICENSE This software is copyright (c) 2012 by Infinity Interactive, Inc. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. =cut 006_metaclass_traits.t100644000765000024 1351311732225161 17653 0ustar00gfxstaff000000000000MouseX-Getopt-0.34/t#!/usr/bin/perl use strict; use warnings; use Test::More tests => 69; use Test::Mouse; BEGIN { use_ok('MouseX::Getopt'); } { package App; use Mouse; with 'MouseX::Getopt'; has 'data' => ( traits => [ 'MouseX::Getopt::Meta::Attribute::Trait' ], is => 'ro', isa => 'Str', default => 'file.dat', cmd_flag => 'f', ); has 'cow' => ( traits => [ 'Getopt' ], is => 'ro', isa => 'Str', default => 'moo', cmd_aliases => [qw/ moocow m c /], ); has 'horse' => ( traits => [ 'Getopt' ], is => 'ro', isa => 'Str', default => 'bray', cmd_flag => 'horsey', cmd_aliases => 'x', ); has 'length' => ( is => 'ro', isa => 'Int', default => 24 ); has 'verbose' => ( is => 'ro', isa => 'Bool', ); has 'libs' => ( is => 'ro', isa => 'ArrayRef', default => sub { [] }, ); has 'details' => ( is => 'ro', isa => 'HashRef', default => sub { {} }, ); has '_private_stuff' => ( is => 'ro', isa => 'Int', default => 713 ); has '_private_stuff_cmdline' => ( traits => [ 'Getopt' ], is => 'ro', isa => 'Int', default => 832, cmd_flag => 'p', ); } foreach my $attr_name (qw(data cow horse _private_stuff_cmdline)) { my $attr = App->meta->get_attribute($attr_name); isa_ok($attr, 'Mouse::Meta::Attribute'); does_ok($attr, 'MouseX::Getopt::Meta::Attribute::Trait'); can_ok($attr, 'cmd_flag'); can_ok($attr, 'cmd_aliases'); } { local @ARGV = (); my $app = App->new_with_options; isa_ok($app, 'App'); ok(!$app->verbose, '... verbosity is off as expected'); is($app->length, 24, '... length is 24 as expected'); is($app->data, 'file.dat', '... data is file.dat as expected'); is_deeply($app->libs, [], '... libs is [] as expected'); is_deeply($app->details, {}, '... details is {} as expected'); } { local @ARGV = ('--verbose', '--length', 50); my $app = App->new_with_options; isa_ok($app, 'App'); ok($app->verbose, '... verbosity is turned on as expected'); is($app->length, 50, '... length is 50 as expected'); is($app->data, 'file.dat', '... data is file.dat as expected'); is_deeply($app->libs, [], '... libs is [] as expected'); is_deeply($app->details, {}, '... details is {} as expected'); } { local @ARGV = ('--verbose', '-f', 'foo.txt'); my $app = App->new_with_options; isa_ok($app, 'App'); ok($app->verbose, '... verbosity is turned on as expected'); is($app->length, 24, '... length is 24 as expected'); is($app->data, 'foo.txt', '... data is foo.txt as expected'); is_deeply($app->libs, [], '... libs is [] as expected'); is_deeply($app->details, {}, '... details is {} as expected'); } { local @ARGV = ('--verbose', '--libs', 'libs/', '--libs', 'includes/lib'); my $app = App->new_with_options; isa_ok($app, 'App'); ok($app->verbose, '... verbosity is turned on as expected'); is($app->length, 24, '... length is 24 as expected'); is($app->data, 'file.dat', '... data is foo.txt as expected'); is_deeply($app->libs, ['libs/', 'includes/lib'], '... libs is [libs/, includes/lib] as expected'); is_deeply($app->details, {}, '... details is {} as expected'); } { local @ARGV = ('--details', 'os=mac', '--details', 'name=foo'); my $app = App->new_with_options; isa_ok($app, 'App'); ok(!$app->verbose, '... verbosity is turned on as expected'); is($app->length, 24, '... length is 24 as expected'); is($app->data, 'file.dat', '... data is foo.txt as expected'); is_deeply($app->libs, [], '... libs is [] as expected'); is_deeply($app->details, { os => 'mac', name => 'foo' }, '... details is { os => mac, name => foo } as expected'); } { # Test negation on booleans too ... local @ARGV = ('--noverbose'); my $app = App->new_with_options; isa_ok($app, 'App'); ok(!$app->verbose, '... verbosity is turned off as expected'); is($app->length, 24, '... length is 24 as expected'); is($app->data, 'file.dat', '... file is file.dat as expected'); is_deeply($app->libs, [], '... libs is [] as expected'); is_deeply($app->details, {}, '... details is {} as expected'); } # Test cmd_alias without cmd_flag { local @ARGV = ('--cow', '42'); my $app = App->new_with_options; isa_ok($app, 'App'); is($app->cow, 42, 'cmd_alias, but not using it'); } { local @ARGV = ('--moocow', '88'); my $app = App->new_with_options; isa_ok($app, 'App'); is($app->cow, 88, 'cmd_alias, using long one'); } { local @ARGV = ('-c', '99'); my $app = App->new_with_options; isa_ok($app, 'App'); is($app->cow, 99, 'cmd_alias, using short one'); } # Test cmd_alias + cmd_flag { local @ARGV = ('--horsey', '123'); my $app = App->new_with_options; isa_ok($app, 'App'); is($app->horse, 123, 'cmd_alias+cmd_flag, using flag'); } { local @ARGV = ('-x', '321'); my $app = App->new_with_options; isa_ok($app, 'App'); is($app->horse, 321, 'cmd_alias+cmd_flag, using alias'); } # Test _foo + cmd_flag { local @ARGV = ('-p', '666'); my $app = App->new_with_options; isa_ok($app, 'App'); is($app->_private_stuff_cmdline, 666, '_foo + cmd_flag'); } # Test ARGV support { my @args = ('-p', 12345, '-c', 99, '-'); local @ARGV = @args; my $app = App->new_with_options; isa_ok($app, 'App'); is_deeply($app->ARGV, \@args, 'ARGV accessor'); is_deeply(\@ARGV, \@args, '@ARGV unmangled'); is_deeply($app->extra_argv, ['-'], 'extra_argv accessor'); } release-pod-coverage.t100644000765000024 76511732225161 17662 0ustar00gfxstaff000000000000MouseX-Getopt-0.34/t#!perl BEGIN { unless ($ENV{RELEASE_TESTING}) { require Test::More; Test::More::plan(skip_all => 'these tests are for release candidate testing'); } } use Test::More; eval "use Test::Pod::Coverage 1.08"; plan skip_all => "Test::Pod::Coverage 1.08 required for testing POD coverage" if $@; eval "use Pod::Coverage::TrustPod"; plan skip_all => "Pod::Coverage::TrustPod required for testing POD coverage" if $@; all_pod_coverage_ok({ coverage_class => 'Pod::Coverage::TrustPod' }); Basic.pm100644000765000024 2076711732225161 20114 0ustar00gfxstaff000000000000MouseX-Getopt-0.34/lib/MouseX/Getoptpackage MouseX::Getopt::Basic; BEGIN { $MouseX::Getopt::Basic::AUTHORITY = 'cpan:STEVAN'; } { $MouseX::Getopt::Basic::VERSION = '0.34'; } # ABSTRACT: MouseX::Getopt::Basic - role to implement the Getopt::Long functionality use Mouse::Role; use MouseX::Getopt::OptionTypeMap; use MouseX::Getopt::Meta::Attribute; use MouseX::Getopt::Meta::Attribute::NoGetopt; use Carp (); use Getopt::Long 2.37 (); has ARGV => (is => 'rw', isa => 'ArrayRef', metaclass => "NoGetopt"); has extra_argv => (is => 'rw', isa => 'ArrayRef', metaclass => "NoGetopt"); sub new_with_options { my ($class, @params) = @_; my $config_from_file; if($class->meta->does_role('MouseX::ConfigFromFile')) { local @ARGV = @ARGV; # just get the configfile arg now; the rest of the args will be # fetched later my $configfile; my $opt_parser = Getopt::Long::Parser->new( config => [ qw( no_auto_help pass_through ) ] ); $opt_parser->getoptions( "configfile=s" => \$configfile ); if(!defined $configfile) { my $cfmeta = $class->meta->find_attribute_by_name('configfile'); $configfile = $cfmeta->default if $cfmeta->has_default; if (ref $configfile eq 'CODE') { # not sure theres a lot you can do with the class and may break some assumptions # warn? $configfile = &$configfile($class); } if (defined $configfile) { $config_from_file = eval { $class->get_config_from_file($configfile); }; if ($@) { die $@ unless $@ =~ /Specified configfile '\Q$configfile\E' does not exist/; } } } else { $config_from_file = $class->get_config_from_file($configfile); } } my $constructor_params = ( @params == 1 ? $params[0] : {@params} ); Carp::croak("Single parameters to new_with_options() must be a HASH ref") unless ref($constructor_params) eq 'HASH'; my %processed = $class->_parse_argv( options => [ $class->_attrs_to_options( $config_from_file ) ], params => $constructor_params, ); my $params = $config_from_file ? { %$config_from_file, %{$processed{params}} } : $processed{params}; # did the user request usage information? if ( $processed{usage} and $params->{help_flag} ) { $class->_getopt_full_usage($processed{usage}); } $class->new( ARGV => $processed{argv_copy}, extra_argv => $processed{argv}, ( $processed{usage} ? ( usage => $processed{usage} ) : () ), %$constructor_params, # explicit params to ->new %$params, # params from CLI ); } sub _getopt_spec { shift->_traditional_spec(@_); } sub _parse_argv { my ( $class, %params ) = @_; local @ARGV = @{ $params{params}{argv} || \@ARGV }; my ( $opt_spec, $name_to_init_arg ) = $class->_getopt_spec(%params); # Get a clean copy of the original @ARGV my $argv_copy = [ @ARGV ]; my @warnings; my ( $parsed_options, $usage ) = eval { local $SIG{__WARN__} = sub { push @warnings, @_ }; return $class->_getopt_get_options(\%params, $opt_spec); }; my $e = $@; $class->_getopt_spec_warnings(@warnings) if @warnings; $class->_getopt_spec_exception(\@warnings, $e) if $e; # Get a copy of the Getopt::Long-mangled @ARGV my $argv_mangled = [ @ARGV ]; my %constructor_args = ( map { $name_to_init_arg->{$_} => $parsed_options->{$_} } keys %$parsed_options, ); return ( params => \%constructor_args, argv_copy => $argv_copy, argv => $argv_mangled, ( defined($usage) ? ( usage => $usage ) : () ), ); } sub _getopt_get_options { my ($class, $params, $opt_spec) = @_; my %options; Getopt::Long::GetOptions(\%options, @$opt_spec); return ( \%options, undef ); } sub _getopt_spec_warnings { } sub _getopt_spec_exception { my ($self, $warnings, $exception) = @_; die @$warnings, $exception; } sub _getopt_full_usage { my ($self, $usage) = @_; $usage->die; } sub _usage_format { return "usage: %c %o"; } sub _traditional_spec { my ( $class, %params ) = @_; my ( @options, %name_to_init_arg, %options ); foreach my $opt ( @{ $params{options} } ) { push @options, $opt->{opt_string}; my $identifier = $opt->{name}; $identifier =~ s/\W/_/g; # Getopt::Long does this to all option names $name_to_init_arg{$identifier} = $opt->{init_arg}; } return ( \@options, \%name_to_init_arg ); } sub _compute_getopt_attrs { my $class = shift; sort { $a->insertion_order <=> $b->insertion_order } grep { $_->does("MouseX::Getopt::Meta::Attribute::Trait") or $_->name !~ /^_/ } grep { !$_->does('MouseX::Getopt::Meta::Attribute::Trait::NoGetopt') } $class->meta->get_all_attributes } sub _get_cmd_flags_for_attr { my ( $class, $attr ) = @_; my $flag = $attr->name; my @aliases; if ($attr->does('MouseX::Getopt::Meta::Attribute::Trait')) { $flag = $attr->cmd_flag if $attr->has_cmd_flag; @aliases = @{ $attr->cmd_aliases } if $attr->has_cmd_aliases; } return ( $flag, @aliases ); } sub _attrs_to_options { my $class = shift; my $config_from_file = shift || {}; my @options; foreach my $attr ($class->_compute_getopt_attrs) { my ( $flag, @aliases ) = $class->_get_cmd_flags_for_attr($attr); my $opt_string = join(q{|}, $flag, @aliases); if ($attr->name eq 'configfile') { $opt_string .= '=s'; } elsif ($attr->has_type_constraint) { my $type = $attr->type_constraint; if (MouseX::Getopt::OptionTypeMap->has_option_type($type)) { $opt_string .= MouseX::Getopt::OptionTypeMap->get_option_type($type) } } push @options, { name => $flag, init_arg => $attr->init_arg, opt_string => $opt_string, required => $attr->is_required && !$attr->has_default && !$attr->has_builder && !exists $config_from_file->{$attr->name}, # NOTE: # this "feature" was breaking because # Getopt::Long::Descriptive would return # the default value as if it was a command # line flag, which would then override the # one passed into a constructor. # See 100_gld_default_bug.t for an example # - SL #( ( $attr->has_default && ( $attr->is_default_a_coderef xor $attr->is_lazy ) ) ? ( default => $attr->default({}) ) : () ), ( $attr->has_documentation ? ( doc => $attr->documentation ) : () ), } } return @options; } no Mouse::Role; 1; __END__ =pod =encoding utf-8 =head1 NAME MouseX::Getopt::Basic - MouseX::Getopt::Basic - role to implement the Getopt::Long functionality =head1 SYNOPSIS ## In your class package My::App; use Mouse; with 'MouseX::Getopt::Basic'; has 'out' => (is => 'rw', isa => 'Str', required => 1); has 'in' => (is => 'rw', isa => 'Str', required => 1); # ... rest of the class here ## in your script #!/usr/bin/perl use My::App; my $app = My::App->new_with_options(); # ... rest of the script here ## on the command line % perl my_app_script.pl --in file.input --out file.dump =head1 DESCRIPTION This is like L and can be used instead except that it doesn't make use of L (or "GLD" for short). =head1 METHODS =head2 new_with_options See L. =head1 AUTHORS =over 4 =item * NAKAGAWA Masaki =item * FUJI Goro =item * Stevan Little =item * Brandon L. Black =item * Yuval Kogman =item * Ryan D Johnson =item * Drew Taylor =item * Tomas Doran =item * Florian Ragwitz =item * Dagfinn Ilmari Mannsaker =item * Avar Arnfjord Bjarmason =item * Chris Prather =item * Mark Gardner =back =head1 COPYRIGHT AND LICENSE This software is copyright (c) 2012 by Infinity Interactive, Inc. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. =cut 002_custom_option_type.t100644000765000024 233011732225161 20223 0ustar00gfxstaff000000000000MouseX-Getopt-0.34/t#!/usr/bin/perl use strict; use warnings; use Test::More tests => 6; BEGIN { use_ok('MouseX::Getopt'); } { package App; use Mouse; use Mouse::Util::TypeConstraints; use Scalar::Util 'looks_like_number'; with 'MouseX::Getopt'; subtype 'ArrayOfInts' => as 'ArrayRef' => where { scalar (grep { looks_like_number($_) } @$_) }; MouseX::Getopt::OptionTypeMap->add_option_type_to_map( 'ArrayOfInts' => '=i@' ); has 'nums' => ( is => 'ro', isa => 'ArrayOfInts', default => sub { [0] } ); } { local @ARGV = (); my $app = App->new_with_options; isa_ok($app, 'App'); is_deeply($app->nums, [0], '... nums is [0] as expected'); } { local @ARGV = ('--nums', 3, '--nums', 5); my $app = App->new_with_options; isa_ok($app, 'App'); is_deeply($app->nums, [3, 5], '... nums is [3, 5] as expected'); } # Make sure it really used our =i@, instead of falling back # to =s@ via the type system, and test that exceptions work # while we're at it. eval { local @ARGV = ('--nums', 3, '--nums', 'foo'); my $app = App->new_with_options; }; like($@, qr/Value "foo" invalid/, 'Numeric constraint enforced'); Dashes.pm100644000765000024 470011732225161 20247 0ustar00gfxstaff000000000000MouseX-Getopt-0.34/lib/MouseX/Getoptpackage MouseX::Getopt::Dashes; BEGIN { $MouseX::Getopt::Dashes::AUTHORITY = 'cpan:STEVAN'; } { $MouseX::Getopt::Dashes::VERSION = '0.34'; } # ABSTRACT: convert underscores in attribute names to dashes use Mouse::Role; with 'MouseX::Getopt'; around _get_cmd_flags_for_attr => sub { my $next = shift; my ( $class, $attr, @rest ) = @_; my ( $flag, @aliases ) = $class->$next($attr, @rest); $flag =~ tr/_/-/ unless $attr->does('MouseX::Getopt::Meta::Attribute::Trait') && $attr->has_cmd_flag; return ( $flag, @aliases ); }; no Mouse::Role; 1; __END__ =pod =encoding utf-8 =head1 NAME MouseX::Getopt::Dashes - convert underscores in attribute names to dashes =head1 SYNOPSIS package My::App; use Mouse; with 'MouseX::Getopt::Dashes'; # Will be called as --some-thingy, not --some_thingy has 'some_thingy' => ( is => 'ro', isa => 'Str', default => 'foo' ); # Will be called as --another_thingy, not --another-thingy has 'another_thingy' => ( traits => [ 'Getopt' ], cmd_flag => 'another_thingy' is => 'ro', isa => 'Str', default => 'foo' ); # use as MouseX::Getopt =head1 DESCRIPTION This is a version of C which converts underscores in attribute names to dashes when generating command line flags. You can selectively disable this on a per-attribute basis by supplying a L argument with the command flag you'd like for a given attribute. No underscore to dash replacement will be done on the C. =head1 AUTHORS =over 4 =item * NAKAGAWA Masaki =item * FUJI Goro =item * Stevan Little =item * Brandon L. Black =item * Yuval Kogman =item * Ryan D Johnson =item * Drew Taylor =item * Tomas Doran =item * Florian Ragwitz =item * Dagfinn Ilmari Mannsaker =item * Avar Arnfjord Bjarmason =item * Chris Prather =item * Mark Gardner =back =head1 COPYRIGHT AND LICENSE This software is copyright (c) 2012 by Infinity Interactive, Inc. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. =cut Strict.pm100644000765000024 322411732225161 20310 0ustar00gfxstaff000000000000MouseX-Getopt-0.34/lib/MouseX/Getoptpackage MouseX::Getopt::Strict; BEGIN { $MouseX::Getopt::Strict::AUTHORITY = 'cpan:STEVAN'; } { $MouseX::Getopt::Strict::VERSION = '0.34'; } # ABSTRACT: only make options for attrs with the Getopt metaclass use Mouse::Role; with 'MouseX::Getopt'; around '_compute_getopt_attrs' => sub { my $next = shift; my ( $class, @args ) = @_; grep { $_->does("MouseX::Getopt::Meta::Attribute::Trait") } $class->$next(@args); }; no Mouse::Role; 1; __END__ =pod =encoding utf-8 =head1 NAME MouseX::Getopt::Strict - only make options for attrs with the Getopt metaclass =head1 DESCRIPTION This is an stricter version of C which only processes the attributes if they explicitly set as C attributes. All other attributes are ignored by the command line handler. =head1 AUTHORS =over 4 =item * NAKAGAWA Masaki =item * FUJI Goro =item * Stevan Little =item * Brandon L. Black =item * Yuval Kogman =item * Ryan D Johnson =item * Drew Taylor =item * Tomas Doran =item * Florian Ragwitz =item * Dagfinn Ilmari Mannsaker =item * Avar Arnfjord Bjarmason =item * Chris Prather =item * Mark Gardner =back =head1 COPYRIGHT AND LICENSE This software is copyright (c) 2012 by Infinity Interactive, Inc. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. =cut 003_inferred_option_type.t100644000765000024 150311732225161 20511 0ustar00gfxstaff000000000000MouseX-Getopt-0.34/t#!/usr/bin/perl use strict; use warnings; use Test::More tests => 5; BEGIN { use_ok('MouseX::Getopt'); } { package App; use Mouse; use Mouse::Util::TypeConstraints; use Scalar::Util 'looks_like_number'; with 'MouseX::Getopt'; subtype 'ArrayOfInts' => as 'ArrayRef' => where { scalar (grep { looks_like_number($_) } @$_) }; has 'nums' => ( is => 'ro', isa => 'ArrayOfInts', default => sub { [0] } ); } { local @ARGV = (); my $app = App->new_with_options; isa_ok($app, 'App'); is_deeply($app->nums, [0], '... nums is [0] as expected'); } { local @ARGV = ('--nums', 3, '--nums', 5); my $app = App->new_with_options; isa_ok($app, 'App'); is_deeply($app->nums, [3, 5], '... nums is [3, 5] as expected'); } 009_gld_and_explicit_options.t100644000765000024 144111732225161 21335 0ustar00gfxstaff000000000000MouseX-Getopt-0.34/t#!/usr/bin/perl use strict; use warnings; use Test::More; use Test::Exception; BEGIN { eval 'use Getopt::Long::Descriptive;'; plan skip_all => "Getopt::Long::Descriptive required for this test" if $@; plan tests => 5; use_ok('MouseX::Getopt'); } { package Testing::Foo; use Mouse; with 'MouseX::Getopt'; has 'bar' => ( is => 'ro', isa => 'Int', required => 1, ); has 'baz' => ( is => 'ro', isa => 'Int', required => 1, ); } @ARGV = qw(--bar 10); my $foo; lives_ok { $foo = Testing::Foo->new_with_options(baz => 100); } '... this should work'; isa_ok($foo, 'Testing::Foo'); is($foo->bar, 10, '... got the right values'); is($foo->baz, 100, '... got the right values'); 110_sort_usage_by_attr_order.t100644000765000024 245611732225161 21363 0ustar00gfxstaff000000000000MouseX-Getopt-0.34/t # The usage information prints the 'documentation' value for all Getopt # attributes, except the order is not deterministic (rather, it uses the order # in which the attributes are stored in the metaclass 'attributes' hash). # Let's sort them by insertion order, which should lead to nicer output: # If MouseX::Getopt is applied early, the help options will be on top # the help options will always be on top (assuming this role is applied # early), followed by options added by parent classes and roles, and then # options added by this class. use strict; use warnings; use Test::More tests => 1; use Test::Exception; { package MyClass; use strict; use warnings; use Mouse; with 'MouseX::Getopt'; has $_ => ( is => 'ro', isa => 'Str', traits => ['Getopt'], documentation => 'Documentation for "' . $_ . '"', ) foreach qw(foo bar baz); } my $obj = MyClass->new_with_options(); my $expected = <<'USAGE'; usage: 110_sort_usage_by_attr_order.t [-?] [long options...] -? --usage --help Prints this usage information. --foo Documentation for "foo" --bar Documentation for "bar" --baz Documentation for "baz" USAGE $expected =~ s/^[ ]{4}/\t/xmsg; is($obj->usage->text, $expected, 'Usage text has nicely sorted options'); OptionTypeMap.pm100644000765000024 646311732225161 21620 0ustar00gfxstaff000000000000MouseX-Getopt-0.34/lib/MouseX/Getoptpackage MouseX::Getopt::OptionTypeMap; BEGIN { $MouseX::Getopt::OptionTypeMap::AUTHORITY = 'cpan:STEVAN'; } { $MouseX::Getopt::OptionTypeMap::VERSION = '0.34'; } # ABSTRACT: Storage for the option to type mappings use Mouse 'confess', 'blessed'; use Mouse::Util::TypeConstraints 'find_type_constraint'; my %option_type_map = ( 'Bool' => '!', 'Str' => '=s', 'Int' => '=i', 'Num' => '=f', 'ArrayRef' => '=s@', 'HashRef' => '=s%', ); sub has_option_type { my (undef, $type_or_name) = @_; return 1 if exists $option_type_map{blessed($type_or_name) ? $type_or_name->name : $type_or_name}; my $current = blessed($type_or_name) ? $type_or_name : find_type_constraint($type_or_name); (defined $current) || confess "Could not find the type constraint for '$type_or_name'"; while (my $parent = $current->parent) { return 1 if exists $option_type_map{$parent->name}; $current = $parent; } return 0; } sub get_option_type { my (undef, $type_or_name) = @_; my $name = blessed($type_or_name) ? $type_or_name->name : $type_or_name; return $option_type_map{$name} if exists $option_type_map{$name}; my $current = ref $type_or_name ? $type_or_name : find_type_constraint($type_or_name); (defined $current) || confess "Could not find the type constraint for '$type_or_name'"; while ( $current = $current->parent ) { return $option_type_map{$current->name} if exists $option_type_map{$current->name}; } return; } sub add_option_type_to_map { my (undef, $type_name, $option_string) = @_; (defined $type_name && defined $option_string) || confess "You must supply both a type name and an option string"; if ( blessed($type_name) ) { $type_name = $type_name->name; } else { (find_type_constraint($type_name)) || confess "The type constraint '$type_name' does not exist"; } $option_type_map{$type_name} = $option_string; } no Mouse::Util::TypeConstraints; no Mouse; 1; __END__ =pod =encoding utf-8 =head1 NAME MouseX::Getopt::OptionTypeMap - Storage for the option to type mappings =head1 DESCRIPTION See the I section in the L docs for more info about how to use this module. =head1 METHODS =head2 B =head2 B =head2 B =head1 AUTHORS =over 4 =item * NAKAGAWA Masaki =item * FUJI Goro =item * Stevan Little =item * Brandon L. Black =item * Yuval Kogman =item * Ryan D Johnson =item * Drew Taylor =item * Tomas Doran =item * Florian Ragwitz =item * Dagfinn Ilmari Mannsaker =item * Avar Arnfjord Bjarmason =item * Chris Prather =item * Mark Gardner =back =head1 COPYRIGHT AND LICENSE This software is copyright (c) 2012 by Infinity Interactive, Inc. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. =cut Meta000755000765000024 011732225161 17227 5ustar00gfxstaff000000000000MouseX-Getopt-0.34/lib/MouseX/GetoptAttribute.pm100644000765000024 610211732225161 21667 0ustar00gfxstaff000000000000MouseX-Getopt-0.34/lib/MouseX/Getopt/Metapackage MouseX::Getopt::Meta::Attribute; BEGIN { $MouseX::Getopt::Meta::Attribute::AUTHORITY = 'cpan:STEVAN'; } { $MouseX::Getopt::Meta::Attribute::VERSION = '0.34'; } # ABSTRACT: Optional meta attribute for custom option names use Mouse; use Mouse::Util::TypeConstraints; extends 'Mouse::Meta::Attribute'; # << Mouse extending Mouse :) with 'MouseX::Getopt::Meta::Attribute::Trait'; no Mouse; # register this as a metaclass alias ... package # stop confusing PAUSE Mouse::Meta::Attribute::Custom::Getopt; sub register_implementation { 'MouseX::Getopt::Meta::Attribute' } 1; __END__ =pod =encoding utf-8 =head1 NAME MouseX::Getopt::Meta::Attribute - Optional meta attribute for custom option names =head1 SYNOPSIS package App; use Mouse; with 'MouseX::Getopt'; has 'data' => ( metaclass => 'MouseX::Getopt::Meta::Attribute', is => 'ro', isa => 'Str', default => 'file.dat', # tells MouseX::Getopt to use --somedata as the # command line flag instead of the normal # autogenerated one (--data) cmd_flag => 'somedata', # tells MouseX::Getopt to also allow --moosedata, # -m, and -d as aliases for this same option on # the commandline. cmd_aliases => [qw/ moosedata m d /], # Or, you can use a plain scalar for a single alias: cmd_aliases => 'm', ); =head1 DESCRIPTION This is a custom attribute metaclass which can be used to specify a the specific command line flag to use instead of the default one which L will create for you. This is certainly not the prettiest way to go about this, but for now it works for those who might need such a feature. =head2 Custom Metaclass alias This now takes advantage of the Moose 0.19 feature to support custom attribute metaclass aliases. This means you can also use this as the B alias, like so: has 'foo' => (metaclass => 'Getopt', cmd_flag => 'f'); =head1 METHODS =head2 B Changes the commandline flag to be this value, instead of the default, which is the same as the attribute name. =head2 B Adds more aliases for this commandline flag, useful for short options and such. =head2 B =head2 B =head1 AUTHORS =over 4 =item * NAKAGAWA Masaki =item * FUJI Goro =item * Stevan Little =item * Brandon L. Black =item * Yuval Kogman =item * Ryan D Johnson =item * Drew Taylor =item * Tomas Doran =item * Florian Ragwitz =item * Dagfinn Ilmari Mannsaker =item * Avar Arnfjord Bjarmason =item * Chris Prather =item * Mark Gardner =back =head1 COPYRIGHT AND LICENSE This software is copyright (c) 2012 by Infinity Interactive, Inc. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. =cut Attribute000755000765000024 011732225161 21172 5ustar00gfxstaff000000000000MouseX-Getopt-0.34/lib/MouseX/Getopt/MetaTrait.pm100644000765000024 622311732225161 22756 0ustar00gfxstaff000000000000MouseX-Getopt-0.34/lib/MouseX/Getopt/Meta/Attributepackage MouseX::Getopt::Meta::Attribute::Trait; BEGIN { $MouseX::Getopt::Meta::Attribute::Trait::AUTHORITY = 'cpan:STEVAN'; } { $MouseX::Getopt::Meta::Attribute::Trait::VERSION = '0.34'; } # ABSTRACT: Optional meta attribute trait for custom option names use Mouse::Role; use Mouse::Util::TypeConstraints; has 'cmd_flag' => ( is => 'rw', isa => 'Str', predicate => 'has_cmd_flag', ); # This subtype is to support scalar -> arrayref coercion # without polluting the built-in types subtype '_MouseX_Getopt_CmdAliases' => as 'ArrayRef'; coerce '_MouseX_Getopt_CmdAliases' => from 'Str' => via { [$_] }; has 'cmd_aliases' => ( is => 'rw', isa => '_MouseX_Getopt_CmdAliases', predicate => 'has_cmd_aliases', coerce => 1, ); no Mouse::Util::TypeConstraints; no Mouse::Role; # register this as a metaclass alias ... package # stop confusing PAUSE Mouse::Meta::Attribute::Custom::Trait::Getopt; sub register_implementation { 'MouseX::Getopt::Meta::Attribute::Trait' } 1; __END__ =pod =encoding utf-8 =head1 NAME MouseX::Getopt::Meta::Attribute::Trait - Optional meta attribute trait for custom option names =head1 SYNOPSIS package App; use Mouse; with 'MouseX::Getopt'; has 'data' => ( traits => [ 'Getopt' ], is => 'ro', isa => 'Str', default => 'file.dat', # tells MouseX::Getopt to use --somedata as the # command line flag instead of the normal # autogenerated one (--data) cmd_flag => 'somedata', # tells MouseX::Getopt to also allow --moosedata, # -m, and -d as aliases for this same option on # the commandline. cmd_aliases => [qw/ moosedata m d /], # Or, you can use a plain scalar for a single alias: cmd_aliases => 'm', ); =head1 DESCRIPTION This is a custom attribute metaclass trait which can be used to specify a the specific command line flag to use instead of the default one which L will create for you. =head1 METHODS =head2 B Changes the commandline flag to be this value, instead of the default, which is the same as the attribute name. =head2 B Adds more aliases for this commandline flag, useful for short options and such. =head2 B =head2 B =head1 AUTHORS =over 4 =item * NAKAGAWA Masaki =item * FUJI Goro =item * Stevan Little =item * Brandon L. Black =item * Yuval Kogman =item * Ryan D Johnson =item * Drew Taylor =item * Tomas Doran =item * Florian Ragwitz =item * Dagfinn Ilmari Mannsaker =item * Avar Arnfjord Bjarmason =item * Chris Prather =item * Mark Gardner =back =head1 COPYRIGHT AND LICENSE This software is copyright (c) 2012 by Infinity Interactive, Inc. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. =cut NoGetopt.pm100644000765000024 412211732225161 23426 0ustar00gfxstaff000000000000MouseX-Getopt-0.34/lib/MouseX/Getopt/Meta/Attributepackage MouseX::Getopt::Meta::Attribute::NoGetopt; BEGIN { $MouseX::Getopt::Meta::Attribute::NoGetopt::AUTHORITY = 'cpan:STEVAN'; } { $MouseX::Getopt::Meta::Attribute::NoGetopt::VERSION = '0.34'; } # ABSTRACT: Optional meta attribute for ignoring params use Mouse; extends 'Mouse::Meta::Attribute'; # << Mouse extending Mouse :) with 'MouseX::Getopt::Meta::Attribute::Trait::NoGetopt'; no Mouse; # register this as a metaclass alias ... package # stop confusing PAUSE Mouse::Meta::Attribute::Custom::NoGetopt; sub register_implementation { 'MouseX::Getopt::Meta::Attribute::NoGetopt' } 1; __END__ =pod =encoding utf-8 =head1 NAME MouseX::Getopt::Meta::Attribute::NoGetopt - Optional meta attribute for ignoring params =head1 SYNOPSIS package App; use Mouse; with 'MouseX::Getopt'; has 'data' => ( metaclass => 'NoGetopt', # do not attempt to capture this param is => 'ro', isa => 'Str', default => 'file.dat', ); =head1 DESCRIPTION This is a custom attribute metaclass which can be used to specify that a specific attribute should B be processed by C. All you need to do is specify the C metaclass. has 'foo' => (metaclass => 'NoGetopt', ... ); =head1 AUTHORS =over 4 =item * NAKAGAWA Masaki =item * FUJI Goro =item * Stevan Little =item * Brandon L. Black =item * Yuval Kogman =item * Ryan D Johnson =item * Drew Taylor =item * Tomas Doran =item * Florian Ragwitz =item * Dagfinn Ilmari Mannsaker =item * Avar Arnfjord Bjarmason =item * Chris Prather =item * Mark Gardner =back =head1 COPYRIGHT AND LICENSE This software is copyright (c) 2012 by Infinity Interactive, Inc. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. =cut Trait000755000765000024 011732225161 22255 5ustar00gfxstaff000000000000MouseX-Getopt-0.34/lib/MouseX/Getopt/Meta/AttributeNoGetopt.pm100644000765000024 404411732225161 24514 0ustar00gfxstaff000000000000MouseX-Getopt-0.34/lib/MouseX/Getopt/Meta/Attribute/Traitpackage MouseX::Getopt::Meta::Attribute::Trait::NoGetopt; BEGIN { $MouseX::Getopt::Meta::Attribute::Trait::NoGetopt::AUTHORITY = 'cpan:STEVAN'; } { $MouseX::Getopt::Meta::Attribute::Trait::NoGetopt::VERSION = '0.34'; } # ABSTRACT: Optional meta attribute trait for ignoring params use Mouse::Role; no Mouse::Role; # register this as a metaclass alias ... package # stop confusing PAUSE Mouse::Meta::Attribute::Custom::Trait::NoGetopt; sub register_implementation { 'MouseX::Getopt::Meta::Attribute::Trait::NoGetopt' } 1; __END__ =pod =encoding utf-8 =head1 NAME MouseX::Getopt::Meta::Attribute::Trait::NoGetopt - Optional meta attribute trait for ignoring params =head1 SYNOPSIS package App; use Mouse; with 'MouseX::Getopt'; has 'data' => ( traits => [ 'NoGetopt' ], # do not attempt to capture this param is => 'ro', isa => 'Str', default => 'file.dat', ); =head1 DESCRIPTION This is a custom attribute metaclass trait which can be used to specify that a specific attribute should B be processed by C. All you need to do is specify the C metaclass trait. has 'foo' => (traits => [ 'NoGetopt', ... ], ... ); =head1 AUTHORS =over 4 =item * NAKAGAWA Masaki =item * FUJI Goro =item * Stevan Little =item * Brandon L. Black =item * Yuval Kogman =item * Ryan D Johnson =item * Drew Taylor =item * Tomas Doran =item * Florian Ragwitz =item * Dagfinn Ilmari Mannsaker =item * Avar Arnfjord Bjarmason =item * Chris Prather =item * Mark Gardner =back =head1 COPYRIGHT AND LICENSE This software is copyright (c) 2012 by Infinity Interactive, Inc. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. =cut