MooseX-App-1.43000755000765000024 014514737355 12461 5ustar00mkostaff000000000000TODO100644000765000024 12314514737355 13206 0ustar00mkostaff000000000000MooseX-App-1.43https://github.com/maros/MooseX-App/issues?q=is%3Aissue+is%3Aopen+label%3AWhishlistChanges100644000765000024 2000714514737355 14054 0ustar00mkostaff000000000000MooseX-App-1.43Release history for Perl module MooseX::App
1.43 2023-10-21
- Remove duplicate license
- Require Config::Any
- Fix cmd_aliases for flags (fixed by William Barker)
- Remove smartmatch (implemented by Petr Pisar)
- Allow to override build date with SOURCE_DATE_EPOCH (implemented by Bernhard M. Wiedemann)
1.42 2021-08-15
- Documentation
- Fix failing tests with new Moose versions (implemented by Frank Schreiner)
- Sort option in bash completion plugin (implemented by Frank Schreiner)
- Fixed term plugin warning (implemented by J.R. Mash)
1.41 2019-05-13
- Switch to Dist::Zilla
1.40 2019-05-13
- Disable 11_process.t on NetBSD since fork is failing (forking is only done
during testing and not by the actual module)
- Sort keys operations to get a predictable order of keys (implemented by Jose Luis Martinez)
- Simplify dependencies: No need for Path::Class. File::Spec and File::Basename that are
loaded via Module::Pluggable::Object are sufficient
1.39 2017-09-24
- APP_DEVELOPER environment for extended module checks
- Improved command checks: Die on single letter flags without Bool type constraints
1.38 2017-06-20
- Cleanups (get rid of smartmatch, inentation, documentation, tests)
- Also handle =head[2-4] tags when processing pod (#47)
- Subcommands (based on work by Yanick Champoux)
1.37 2016-11-13
- Refactor the way values are parsed from @ARGV
- Rework boolean negation
- Add developer checks
1.36 2016-10-11
- Documentation
- Set correct encoding on STDERR
- Fix order of options (fixed by J.R. Mash)
- Replace dashes in variable names with underscores in bash completion
(implemented byTina Müller)
- Do not autocomplete autocomplete itself (implemented by Lisa Hare)
- Create correct documentation for options with cmd_split
- Rename hints key to clarify purpose
- Add ability to negate boolean options (implemented by Marc Logghe)
- Spelling fixes github#39 (fixed by Gregor Herrmann)
- Retain original order of elements from @ARGV
1.35 2016-04-02
- Spelling fixes RT112234 (fixed by Gregor Herrmann)
- Documentation
- Allow to pass ARGV directly to constructor
- use namespace::autoclean (reported by Mohammad S Anwar)
- Dist housekeeping
1.34 2016-02-21
- Do not accept invalid character in Term plugin
- Fix RT112156: Command class lacking attribute metarole (reported by Marc Logghe)
- Apply Spelling fixes RT105717 (fixed by Gregor Herrmann)
- Add permute option to specify multiple values with one attribute key
- Fix imports (fixed by Alexander Stoddard)
- Documentation
1.33 2015-04-17
- Fix failing tests
- Fix manifest
1.32 2015-03-21
- Improved Term Plugin (History, Delete, Pasting, Pos1/End, Cursors)
- Documentation
- Added app_command_register
- Errors are now printed on STDERR
- Disable fuzzy match for single letter parameters
- Use proper exit codes if errors occur
- Add tests for subprocesses
- Add MutexGroup plugin (implemented by Hunter McMillen)
- Add Depends plugin (implemented by Hunter McMillen)
1.31 2015-02-08
- Dist cleanup (done by Sergey Romanov)
- Moose cleanups (done by Sawyer X)
- Fixed TERM plugin input
- Coercion for ENV variables (implemented by Roman F.)
- Refactor handling of boolean values
- Allow for empty values
- Add cmd_count option for counter attributes
1.30 2014-08-24
- Better error message if command was not specified
- Help improved
- Term plugin
- Deprecate Env plugin; Now in core
- Fix broken usage in M::A::Simple
- Fix documentation being parsed called multiple times
1.29 2014-08-05
- Documentation improvements and fixups
- Better error messages if type constraints fail
- Better suggestions in case of errors
- Handle enum type constraints in usage info
- Display application documentation
1.28 2014-03-25
- Fix failing tests (reported by Michael Greb and Dagfinn Ilmari Mannsåker)
1.27 2014-03-02
- Fix warnings on warnings on 5.18 again
- Documentation
- Fix spelling (fixed by Gregor Herrmann)
1.26 2014-02-24
- Fix failing tests
1.25 2014-02-23
- Allow multiple command namespaces (implemented by Thilo Fester)
- Documentation
1.24 2014-02-14
- Fix POD warnings (fixed by David Golden)
- Always reuse existing MooseX::App::ParsedArgv instances
- Parse @ARGV as soon as possible
- Fix Win32 colorisation issues (fixed by J.R. Mash)
- Add app_prefer_commandline option
1.23 2014-01-27
- Documentation
- Manual plugin
- More inheritance tests
- Cleanup deprecated code
1.22 2013-05-24
- Silence experimental::smartmatch warnings on 5.18 (fixed by Mike Doherty)
1.21 2013-04-13
- Fix option sorting
- Fix parsing of positional parameters
1.20 2013-04-08
- Add cmd_split and cmd_position option
- Fixed parameter position (fixed by Yanick Champoux)
- app_strict option to set if app should terminate when unknown parameters
or options are supplied
1.19 2013-03-28
- Fixed failing tests
- Fixed bug that was triggered by Moose 2.0800
- Fixed on MSWin
1.18 2013-03-24
- Added positional parameters with 'parameter' keyword
(Attention: this change might break things if you used to work with @extra)
- Parameters are handled in the meta class
- Usage meta class methods refactored
1.17 2013-03-06
- Fix failing tests
1.16 2013-02-27
- Better license parsing
- Fix failing tests
- Use Class::Load instead of Class::MOP to load classes
- Remove MooseX::Getopt dependency. Parse @ARGV ourself
- Renamed meta class methods to use single prefix
- Moved meta class methods to attribute meta class
- Much more tests (95% statement and 90% total coverage)
- Better error handling for Environment plugin
1.15 2013-01-18
- Fix wrong attribute initialisation order
1.14 2013-01-15
- Fix failing test
- Update documentation
- Optional usage information from POD (implemented by Yanick Champoux)
- app_fuzzy now defaults to true
- Version plugin prints license and copyright
1.13 2013-01-11
- Fix failing test
- Update documentation
1.12 2013-01-10
- Fix failing test
- Fix pod (Andrew Jones)
1.11 2013-01-08
- Parse DistZilla ABSTRACT for documentation
- Improve tutorial and fix typo (fixed by George Hartzell)
- Saner bash completion and version plugin
- Fix fuzzy command and attribute matching
- Deprecate fuzzy plugin, use typo plugin instead
- Handle shell character encodings
- More tests
1.10 2013-01-07
- Fix bash completion plugin (fixed by Steve Nolte)
1.09 2012-11-22
- Fix failing load test
1.08 2012-11-17
- Refactor object initialisation
- Fix missing bash-completion prefix (fixed by Steve Nolte)
- Require latest MooseX::Getopt (fixed by Steve Nolte)
- Fix Plugin::Version docs RT81186 (fixed by Michael G)
- Update documentation
1.07 2012-08-22
- Fix failing load tests
1.06 2012-08-20
- Single command interface (MooseX::App::Simple)
- Fuzzy command matching plugin
- Only lowercase command names
- Environment plugin
- Version plugin
- Various cleanups
1.05 2012-06-04
- Fix broken load tests
- Join M::A::Meta::Attribute::Base and M::A::Meta::Attribute::Option
1.04 2012-06-02
- Fix bugs in BashCompletion plugin
- Remove code duplication
- Fix --help flag in command classes
- Fix pod to text conversion
1.03 2012-06-02
- Do not expose all attributes as options but only those defined via
'option' keyword
- More tests
- Internal changes (move methods to meta class, calculate loadable commands
only once, ...)
- Fix various bugs
1.02 2012-04-15
- Fix command usage generation bug
- Automatically apply MooseX-Getopt attribute traits
- Rename command_tag to cmd_tag attribute
1.01 2012-04-12
- Fix text failures
- Fix Pod
- Add missing tutorials to manifest
1.00 2012-04-07
- Initial version
LICENSE100644000765000024 4643514514737355 13603 0ustar00mkostaff000000000000MooseX-App-1.43This software is copyright (c) 2023 by Maroš Kollár.
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) 2023 by Maroš Kollár.
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, Fifth Floor, Boston, MA 02110-1301 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 Perl Artistic License 1.0 ---
This software is Copyright (c) 2023 by Maroš Kollár.
This is free software, licensed under:
The Perl Artistic License 1.0
The "Artistic License"
Preamble
The intent of this document is to state the conditions under which a
Package may be copied, such that the Copyright Holder maintains some
semblance of artistic control over the development of the package,
while giving the users of the package the right to use and distribute
the Package in a more-or-less customary fashion, plus the right to make
reasonable modifications.
Definitions:
"Package" refers to the collection of files distributed by the
Copyright Holder, and derivatives of that collection of files
created through textual modification.
"Standard Version" refers to such a Package if it has not been
modified, or has been modified in accordance with the wishes
of the Copyright Holder as specified below.
"Copyright Holder" is whoever is named in the copyright or
copyrights for the package.
"You" is you, if you're thinking about copying or distributing
this Package.
"Reasonable copying fee" is whatever you can justify on the
basis of media cost, duplication charges, time of people involved,
and so on. (You will not be required to justify it to the
Copyright Holder, but only to the computing community at large
as a market that must bear the fee.)
"Freely Available" means that no fee is charged for the item
itself, though there may be fees involved in handling the item.
It also means that recipients of the item may redistribute it
under the same conditions they received it.
1. You may make and give away verbatim copies of the source form of the
Standard Version of this Package without restriction, provided that you
duplicate all of the original copyright notices and associated disclaimers.
2. You may apply bug fixes, portability fixes and other modifications
derived from the Public Domain or from the Copyright Holder. A Package
modified in such a way shall still be considered the Standard Version.
3. You may otherwise modify your copy of this Package in any way, provided
that you insert a prominent notice in each changed file stating how and
when you changed that file, and provided that you do at least ONE of the
following:
a) place your modifications in the Public Domain or otherwise make them
Freely Available, such as by posting said modifications to Usenet or
an equivalent medium, or placing the modifications on a major archive
site such as uunet.uu.net, or by allowing the Copyright Holder to include
your modifications in the Standard Version of the Package.
b) use the modified Package only within your corporation or organization.
c) rename any non-standard executables so the names do not conflict
with standard executables, which must also be provided, and provide
a separate manual page for each non-standard executable that clearly
documents how it differs from the Standard Version.
d) make other distribution arrangements with the Copyright Holder.
4. You may distribute the programs of this Package in object code or
executable form, provided that you do at least ONE of the following:
a) distribute a Standard Version of the executables and library files,
together with instructions (in the manual page or equivalent) on where
to get the Standard Version.
b) accompany the distribution with the machine-readable source of
the Package with your modifications.
c) give non-standard executables non-standard names, and clearly
document the differences in manual pages (or equivalent), together
with instructions on where to get the Standard Version.
d) make other distribution arrangements with the Copyright Holder.
5. You may charge a reasonable copying fee for any distribution of this
Package. You may charge any fee you choose for support of this
Package. You may not charge a fee for this Package itself. However,
you may distribute this Package in aggregate with other (possibly
commercial) programs as part of a larger (possibly commercial) software
distribution provided that you do not advertise this Package as a
product of your own. You may embed this Package's interpreter within
an executable of yours (by linking); this shall be construed as a mere
form of aggregation, provided that the complete Standard Version of the
interpreter is so embedded.
6. The scripts and library files supplied as input to or produced as
output from the programs of this Package do not automatically fall
under the copyright of this Package, but belong to whoever generated
them, and may be sold commercially, and may be aggregated with this
Package. If such scripts or library files are aggregated with this
Package via the so-called "undump" or "unexec" methods of producing a
binary executable image, then distribution of such an image shall
neither be construed as a distribution of this Package nor shall it
fall under the restrictions of Paragraphs 3 and 4, provided that you do
not represent such an executable image as a Standard Version of this
Package.
7. C subroutines (or comparably compiled subroutines in other
languages) supplied by you and linked into this Package in order to
emulate subroutines and variables of the language defined by this
Package shall not be considered part of this Package, but are the
equivalent of input as in Paragraph 6, provided these subroutines do
not change the language in any way that would cause it to fail the
regression tests for the language.
8. Aggregation of this Package with a commercial distribution is always
permitted provided that the use of this Package is embedded; that is,
when no overt attempt is made to make this Package's interfaces visible
to the end user of the commercial distribution. Such use shall not be
construed as a distribution of this Package.
9. The name of the Copyright Holder may not be used to endorse or promote
products derived from this software without specific prior written permission.
10. THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR
IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
The End
cpanfile100644000765000024 152614514737355 14252 0ustar00mkostaff000000000000MooseX-App-1.43requires 'Moose', '2.00';
requires 'namespace::autoclean';
requires 'Module::Pluggable';
requires 'File::Basename';
requires 'File::Spec';
requires 'List::Util', '1.44';
requires 'Pod::Elemental';
requires 'Config::Any';
feature 'config', 'Config plugins' => sub {
requires 'File::HomeDir';
};
feature 'colour', 'Colourful output' => sub {
requires 'IO::Interactive';
requires 'Term::ANSIColor';
requires 'Win32::Console::ANSI';
};
feature 'term', 'Term plugin' => sub {
requires 'IO::Interactive';
requires 'Term::ANSIColor';
};
feature 'typo', 'Typo plugin' => sub {
requires 'Text::WagnerFischer';
};
on test => sub {
requires 'Test::Most';
requires 'Test::NoWarnings';
};
on develop => sub {
requires 'Test::Pod', '1.14';
requires 'Test::Pod::Coverage', '1.04';
requires 'Test::Perl::Critic';
};
dist.ini100644000765000024 111714514737355 14206 0ustar00mkostaff000000000000MooseX-App-1.43name = MooseX-App
author = Maroš Kollár
license = Perl_5
copyright_holder = Maroš Kollár
copyright_year = 2023
main_module = lib/MooseX/App.pm
[Git::GatherDir]
exclude_match=Makefile
exclude_match=LICENSE
[MakeMaker]
[VersionFromMainModule]
[MetaYAML]
[MetaJSON]
[MinimumPerlFast]
[MetaResources]
repository.web = https://github.com/maros/MooseX-App
repository.url = git://github.com/maros/MooseX-App.git
repository.type = git
bugtracker.web = https://github.com/maros/MooseX-App/issues
[License]
[RunExtraTests]
[TestRelease]
[Manifest]
[Prereqs::FromCPANfile]
xt000755000765000024 014514737355 13035 5ustar00mkostaff000000000000MooseX-App-1.43pod.t100644000765000024 35614514737355 14130 0ustar00mkostaff000000000000MooseX-App-1.43/xt# -*- perl -*-
use strict;
use warnings;
use Test::More;
eval "use Test::Pod 1.14";
plan skip_all => 'Test::Pod 1.14 required' if $@;
plan skip_all => 'set TEST_AUTHOR to enable this test' unless $ENV{TEST_AUTHOR};
all_pod_files_ok();
META.yml100644000765000024 252214514737355 14014 0ustar00mkostaff000000000000MooseX-App-1.43---
abstract: 'Write user-friendly command line apps with even less suffering'
author:
- 'Maroš Kollár '
build_requires:
Test::Most: '0'
Test::NoWarnings: '0'
configure_requires:
ExtUtils::MakeMaker: '0'
dynamic_config: 0
generated_by: 'Dist::Zilla version 6.030, CPAN::Meta::Converter version 2.150010'
license: perl
meta-spec:
url: http://module-build.sourceforge.net/META-spec-v1.4.html
version: '1.4'
name: MooseX-App
optional_features:
colour:
description: 'Colourful output'
requires:
IO::Interactive: '0'
Term::ANSIColor: '0'
Win32::Console::ANSI: '0'
config:
description: 'Config plugins'
requires:
File::HomeDir: '0'
term:
description: 'Term plugin'
requires:
IO::Interactive: '0'
Term::ANSIColor: '0'
typo:
description: 'Typo plugin'
requires:
Text::WagnerFischer: '0'
requires:
Config::Any: '0'
File::Basename: '0'
File::Spec: '0'
List::Util: '1.44'
Module::Pluggable: '0'
Moose: '2.00'
Pod::Elemental: '0'
namespace::autoclean: '0'
perl: '5.010'
resources:
bugtracker: https://github.com/maros/MooseX-App/issues
repository: git://github.com/maros/MooseX-App.git
version: '1.43'
x_generated_by_perl: v5.30.3
x_serialization_backend: 'YAML::Tiny version 1.73'
x_spdx_expression: 'Artistic-1.0-Perl OR GPL-1.0-or-later'
MANIFEST100644000765000024 634714514737355 13705 0ustar00mkostaff000000000000MooseX-App-1.43# This file was automatically generated by Dist::Zilla::Plugin::Manifest v6.030.
Changes
LICENSE
MANIFEST
META.json
META.yml
Makefile.PL
README.md
TODO
cpanfile
dist.ini
lib/MooseX/App.pm
lib/MooseX/App/Command.pm
lib/MooseX/App/Exporter.pm
lib/MooseX/App/Message/Block.pm
lib/MooseX/App/Message/BlockColor.pm
lib/MooseX/App/Message/Envelope.pm
lib/MooseX/App/Meta/Role/Attribute/Option.pm
lib/MooseX/App/Meta/Role/Class/Base.pm
lib/MooseX/App/Meta/Role/Class/Command.pm
lib/MooseX/App/Meta/Role/Class/Documentation.pm
lib/MooseX/App/Meta/Role/Class/Simple.pm
lib/MooseX/App/ParsedArgv.pm
lib/MooseX/App/ParsedArgv/Element.pm
lib/MooseX/App/ParsedArgv/Value.pm
lib/MooseX/App/Plugin/BashCompletion.pm
lib/MooseX/App/Plugin/BashCompletion/Command.pm
lib/MooseX/App/Plugin/BashCompletion/Meta/Class.pm
lib/MooseX/App/Plugin/Color.pm
lib/MooseX/App/Plugin/Color/Meta/Class.pm
lib/MooseX/App/Plugin/Config.pm
lib/MooseX/App/Plugin/Config/Meta/Class.pm
lib/MooseX/App/Plugin/ConfigHome.pm
lib/MooseX/App/Plugin/ConfigHome/Meta/Class.pm
lib/MooseX/App/Plugin/Depends.pm
lib/MooseX/App/Plugin/Depends/Meta/Attribute.pm
lib/MooseX/App/Plugin/Depends/Meta/Class.pm
lib/MooseX/App/Plugin/Env.pm
lib/MooseX/App/Plugin/Fuzzy.pm
lib/MooseX/App/Plugin/Man.pm
lib/MooseX/App/Plugin/Man/Command.pm
lib/MooseX/App/Plugin/Man/Meta/Class.pm
lib/MooseX/App/Plugin/MutexGroup.pm
lib/MooseX/App/Plugin/MutexGroup/Meta/Attribute.pm
lib/MooseX/App/Plugin/MutexGroup/Meta/Class.pm
lib/MooseX/App/Plugin/Term.pm
lib/MooseX/App/Plugin/Term/Meta/Attribute.pm
lib/MooseX/App/Plugin/Term/Meta/Class.pm
lib/MooseX/App/Plugin/Typo.pm
lib/MooseX/App/Plugin/Typo/Meta/Class.pm
lib/MooseX/App/Plugin/Version.pm
lib/MooseX/App/Plugin/Version/Command.pm
lib/MooseX/App/Plugin/Version/Meta/Class.pm
lib/MooseX/App/Role.pm
lib/MooseX/App/Role/Base.pm
lib/MooseX/App/Role/Common.pm
lib/MooseX/App/Simple.pm
lib/MooseX/App/Tutorial.pod
lib/MooseX/App/Utils.pm
lib/MooseX/App/WritingPlugins.pod
meta/argv.pl
t/00_load.t
t/01_basic.t
t/02_meta.t
t/03_utils.t
t/04_plugin_config.t
t/05_extended.t
t/06_env.t
t/07_single.t
t/08_plugin_various.t
t/09_classes.t
t/10_plugin_mutexgroup.t
t/11_process.t
t/12_plugin_depends.t
t/13_rt_112156.t
t/14_gh_45.t
t/15_subcommands.t
t/16_rt122946.t
t/config.pl
t/example/test01.pl
t/example/test02.pl
t/example/test03.pl
t/example/test04.pl
t/example/test05.pl
t/example/test06.pl
t/example/test07.pl
t/example/test08.pl
t/example/test_synopsis.pl
t/testlib/Test01.pm
t/testlib/Test01/CommandA.pm
t/testlib/Test01/CommandB.pm
t/testlib/Test01/CommandC1.pm
t/testlib/Test01/CommandD.pm
t/testlib/Test02.pm
t/testlib/Test02/Command/Error.pm
t/testlib/Test02/Command/Record.pm
t/testlib/Test02/Command/Required.pm
t/testlib/Test02/MoreCommands/Test.pm
t/testlib/Test03.pm
t/testlib/Test03/AnotherCommand.pm
t/testlib/Test03/BrokenCommand.pm
t/testlib/Test03/DifferentCommand.pm
t/testlib/Test03/ExtraCommand.pm
t/testlib/Test03/Role/TestRole.pm
t/testlib/Test03/SomeCommand.pm
t/testlib/Test03/YetAnotherCommand.pm
t/testlib/Test03CommandBase.pm
t/testlib/Test04.pm
t/testlib/Test04Base.pm
t/testlib/Test05.pm
t/testlib/Test06.pm
t/testlib/Test06/CommandA.pm
t/testlib/Test06/CommandB.pm
t/testlib/Test06/CommandD.pm
t/testlib/Test07.pm
t/testlib/Test08.pm
xt/perlcritic.t
xt/pod.t
xt/podcoverage.t
xt/podstyle.t
README.md100644000765000024 4242614514737355 14051 0ustar00mkostaff000000000000MooseX-App-1.43# NAME
MooseX::App - Write user-friendly command line apps with even less suffering
# SYNOPSIS
In your base class:
package MyApp;
use MooseX::App qw(Color);
option 'global_option' => (
is => 'rw',
isa => 'Bool',
documentation => q[Enable this to do fancy stuff],
); # Global option
has 'private' => (
is => 'rw',
); # not exposed
Write multiple command classes (If you have only a single command class
you should use [MooseX::App::Simple](https://metacpan.org/pod/MooseX%3A%3AApp%3A%3ASimple) instead). Packackes in the namespace may be
deeply nested.
package MyApp::SomeCommand;
use MooseX::App::Command; # important (also imports Moose)
extends qw(MyApp); # optional, only if you want to use global options from base class
# Positional parameter
parameter 'some_parameter' => (
is => 'rw',
isa => 'Str',
required => 1,
documentation => q[Some parameter that you need to supply],
);
option 'some_option' => (
is => 'rw',
isa => 'Int',
required => 1,
documentation => q[Very important option!],
); # Option
sub run {
my ($self) = @_;
# Do something
}
And then you need a simple wrapper script (called eg. myapp):
#!/usr/bin/env perl
use MyApp;
MyApp->new_with_command->run;
On the command line:
bash$ myapp help
usage:
myapp [long options...]
myapp help
global options:
--global_option Enable this to do fancy stuff [Flag]
--help --usage -? Prints this usage information. [Flag]
available commands:
some_command Description of some command
another_command Description of another command
help Prints this usage information
or
bash$ myapp some_command --help
usage:
myapp some_command [long options...]
myapp help
myapp some_command --help
parameters:
some_parameter Some parameter that you need to supply [Required]
options:
--global_option Enable this to do fancy stuff [Flag]
--some_option Very important option! [Int,Required]
--help --usage -? Prints this usage information. [Flag]
# DESCRIPTION
MooseX-App is a highly customisable helper to write user-friendly
command line applications without having to worry about most of the annoying
things usually involved. Just take any existing [Moose](https://metacpan.org/pod/Moose) class, add a single
line (`use MooseX-App qw(PluginA PluginB ...);`) and create one class
for each command in an underlying namespace. Options and positional parameters
can be defined as simple [Moose](https://metacpan.org/pod/Moose) accessors using the `option` and
`parameter` keywords respectively.
MooseX-App will then
- Find, load and initialise the command classes (see
[MooseX::App::Simple](https://metacpan.org/pod/MooseX%3A%3AApp%3A%3ASimple) for single class/command applications)
- Create automated help and documentation from modules POD as well as
attributes metadata and type constraints
- Read, encode and validate the command line options and positional
parameters entered by the user from @ARGV and %ENV (and possibly prompt
the user for additional parameters see [MooseX::App::Plugin::Term](https://metacpan.org/pod/MooseX%3A%3AApp%3A%3APlugin%3A%3ATerm))
- Provide helpful error messages if user input cannot be validated
(either missing or wrong attributes or Moose type constraints not satisfied)
or if the user requests help.
Commandline options are defined using the 'option' keyword which accepts
the same attributes as Moose' 'has' keyword.
option 'some_option' => (
is => 'rw',
isa => 'Str',
);
This is equivalent to
has 'some_option' => (
is => 'rw',
isa => 'Str',
traits => ['AppOption'], # Load extra metaclass
cmd_type => 'option', # Set attribute type
);
Single letter options are treated as flags and may be combined with each other.
However such options must have a Boolean type constraint.
option 'verbose' => (
is => 'rw',
isa => 'Bool',
cmd_flag => 'v',
);
Positional parameters are defined with the 'parameter' keyword
parameter 'some_option' => (
is => 'rw',
isa => 'Str',
);
This is equivalent to
has 'some_option' => (
is => 'rw',
isa => 'Str',
traits => ['AppOption'],
cmd_type => 'parameter',
);
All keywords are imported by [Moosex::App](https://metacpan.org/pod/Moosex%3A%3AApp) (in the app base class) and
[MooseX::App::Command](https://metacpan.org/pod/MooseX%3A%3AApp%3A%3ACommand) (in the command class) or [MooseX::App::Simple](https://metacpan.org/pod/MooseX%3A%3AApp%3A%3ASimple)
(single class application).
Furthermore, all options and parameters can also be supplied via %ENV
option 'some_option' => (
is => 'rw',
isa => 'Str',
cmd_env => 'SOME_OPTION', # sets the env key
);
Moose type constraints help MooseX::App to construct helpful error messages
and parse @ARGV in a meaningful way. The following type constraints are
supported:
- ArrayRef: Specify multiple values ('--opt value1 --opt value2',
also see [app\_permute](https://metacpan.org/pod/app_permute) and [cmd\_split](https://metacpan.org/pod/cmd_split))
- HashRef: Specify multiple key value pairs ('--opt key=value --opt
key2=value2', also see [app\_permute](https://metacpan.org/pod/app_permute))
- Enum: Display all possibilities
- Bool: Flags that do not require values
- Int, Num: Used for proper error messages
Read the [Tutorial](https://metacpan.org/pod/MooseX%3A%3AApp%3A%3ATutorial) for getting started with a simple
MooseX::App command line application.
# METHODS
## new\_with\_command
my $myapp_command = MyApp->new_with_command();
This constructor reads the command line arguments and tries to create a
command class instance. If it fails it returns a
[MooseX::App::Message::Envelope](https://metacpan.org/pod/MooseX%3A%3AApp%3A%3AMessage%3A%3AEnvelope) object holding an error message.
You can pass a hash of default/fallback params to new\_with\_command
my $obj = MyApp->new_with_command(%default);
Optionally you can pass a custom ARGV to this constructor
my $obj = MyApp->new_with_command( ARGV => \@myARGV );
However, if you do so you must take care of propper @ARGV encoding yourself.
## initialize\_command\_class
my $obj = MyApp->initialize_command_class($command_name,%default);
Helper method to instantiate the command class for the given command.
# GLOBAL OPTIONS
These options may be used to alter the default behaviour of MooseX-App.
## app\_base
app_base 'my_script'; # Defaults to $0
Usually MooseX::App will take the name of the calling wrapper script to
construct the program name in various help messages. This name can
be changed via the app\_base function.
## app\_fuzzy
app_fuzzy 1; # default
OR
app_fuzzy 0;
Enables fuzzy matching of commands and attributes. Is turned on by default.
## app\_strict
app_strict 0; # default
OR
app_strict 1;
If strict is enabled the program will terminate with an error message if
superfluous/unknown positional parameters are supplied. If disabled all
extra parameters will be copied to the [extra\_argv](https://metacpan.org/pod/extra_argv) attribute. Unknown
options (with leading dashes) will always yield an error message.
The command\_strict config in the command classes allows one to set this option
individually for each command in the respective command class.
## app\_prefer\_commandline
app_prefer_commandline 0; # default
or
app_prefer_commandline 1;
Specifies if parameters/options supplied via @ARGV,%ENV should take precedence
over arguments passed directly to new\_with\_command.
## app\_namespace
app_namespace 'MyApp::Commands', 'YourApp::MoreCommands';
OR
app_namespace();
Usually MooseX::App will take the package name of the base class as the
namespace for commands. This namespace can be changed and you can add
multiple extra namespaces.
If app\_namespace is called with no arguments then autoloading of command
classes will be disabled entirely.
## app\_exclude
app_exclude 'MyApp::Commands::Roles','MyApp::Commands::Utils';
A sub namespace included via [app\_namespace](https://metacpan.org/pod/app_namespace) (or the default behaviour) can
be excluded using app\_exclude.
## app\_command\_name
app_command_name {
my ($package_short,$package_full) = @_;
# munge package name;
return $command_name;
};
This coderef can be used to control how autoloaded package names should be
translated to command names. If this command returns nothing the respective
command class will be skipped and not loaded.
## app\_command\_register
app_command_register
do => 'MyApp::Commands::DoSomething',
undo => 'MyApp::Commands::UndoSomething';
This keyword can be used to register additional commands. Especially
useful in conjunction with [app\_namespace](https://metacpan.org/pod/app_namespace) and disabled autoloading.
## app\_description
app_description qq[Description text];
Set the app description text. If not set this information will be taken from
the Pod DESCRIPTION or OVERVIEW sections. (see command\_description to set
usage per command)
## app\_usage
app_usage qq[myapp --option ...];
Set a custom usage text. If not set this will be taken from the Pod SYNOPSIS
or USAGE section. If both sections are not available, the usage information
will be autogenerated. (see command\_usage to set usage per command)
## app\_permute
app_permute 0; # default
OR
app_permute 1;
Allows one to specify multiple values with one key. So instead of writing
`--list element1 --list element2 --list element3` one might write
`--list element1 element2 element3` for ArrayRef elements. HashRef elements
may be expressed as `--hash key=value key2=value2`.
# GLOBAL ATTRIBUTES
All MooseX::App classes will have two extra attributes
## extra\_argv
Carries all parameters from @ARGV that were not consumed (only if app\_strict
is turned off, otherwise superfluous parameters will raise an exception).
## help\_flag
Help flag that is set when help was requested.
# ATTRIBUTE OPTIONS
Options and parameters accept extra attributes for customisation:
- cmd\_tags - Extra tags (as used by the help)
- cmd\_flag - Override option/parameter name
- cmd\_aliases - Additional option/parameter name aliases
- cmd\_split - Split values into ArrayRefs on this token or RegEx
- cmd\_position - Specify option/parameter order in help
- cmd\_env - Read options/parameters from %ENV
- cmd\_count - Value of option equals to number of occurrences in @ARGV
- cmd\_negate - Adds an option to negate boolean flags
Refer to [MooseX::App::Meta::Role::Attribute::Option](https://metacpan.org/pod/MooseX%3A%3AApp%3A%3AMeta%3A%3ARole%3A%3AAttribute%3A%3AOption) for detailed
documentation.
# METADATA
MooseX::App will use your class metadata and POD to construct the commands and
helpful error- or usage-messages. These bits of information are utilised
and should be provided if possible:
- Package names
- [required](https://metacpan.org/pod/Moose#required----1-0) options for Moose attributes
- [documentation](https://metacpan.org/pod/Moose#documentation-string) options for Moose attributes
- Moose type constraints (Bool, ArrayRef, HashRef, Int, Num, and Enum)
- Documentation set via app\_description, app\_usage,
command\_short\_description, command\_long\_description and command\_usage
- POD (NAME, ABSTRACT, DESCRIPTION, USAGE, SYNOPSIS, OVERVIEW,
COPYRIGHT, LICENSE, COPYRIGHT AND LICENSE, AUTHOR and AUTHORS sections)
- [Dist::Zilla](https://metacpan.org/pod/Dist%3A%3AZilla) ABSTRACT tag if no POD is available yet
# PLUGINS
The behaviour of MooseX-App can be customised with plugins. To load a
plugin just pass a list of plugin names after the `use MooseX-App` statement.
(Attention: order sometimes matters)
use MooseX::App qw(PluginA PluginB);
Currently the following plugins are shipped with MooseX::App
- [MooseX::App::Plugin::BashCompletion](https://metacpan.org/pod/MooseX%3A%3AApp%3A%3APlugin%3A%3ABashCompletion)
Adds a command that generates a bash completion script for your application.
See third party [MooseX::App::Plugin::ZshCompletion](https://metacpan.org/pod/MooseX%3A%3AApp%3A%3APlugin%3A%3AZshCompletion) for Z shell completion.
- [MooseX::App::Plugin::Color](https://metacpan.org/pod/MooseX%3A%3AApp%3A%3APlugin%3A%3AColor)
Colorful output for your MooseX::App applications.
- [MooseX::App::Plugin::Config](https://metacpan.org/pod/MooseX%3A%3AApp%3A%3APlugin%3A%3AConfig)
Config files for MooseX::App applications.
- [MooseX::App::Plugin::ConfigHome](https://metacpan.org/pod/MooseX%3A%3AApp%3A%3APlugin%3A%3AConfigHome)
Try to find config files in users home directory.
- [MooseX::App::Plugin::Term](https://metacpan.org/pod/MooseX%3A%3AApp%3A%3APlugin%3A%3ATerm)
Prompt user for options and parameters that were not provided via options or
params. Prompt offers basic editing capabilities and non-persistent history.
- [MooseX::App::Plugin::Typo](https://metacpan.org/pod/MooseX%3A%3AApp%3A%3APlugin%3A%3ATypo)
Handle typos in command names and provide suggestions.
- [MooseX::App::Plugin::Version](https://metacpan.org/pod/MooseX%3A%3AApp%3A%3APlugin%3A%3AVersion)
Adds a command to display the version and license of your application.
- [MooseX::App::Plugin::Man](https://metacpan.org/pod/MooseX%3A%3AApp%3A%3APlugin%3A%3AMan)
Display full manpage of application and commands.
- [MooseX::App::Plugin::MutexGroup](https://metacpan.org/pod/MooseX%3A%3AApp%3A%3APlugin%3A%3AMutexGroup)
Allow for mutally exclusive options.
- [MooseX::App::Plugin::Depends](https://metacpan.org/pod/MooseX%3A%3AApp%3A%3APlugin%3A%3ADepends)
Adds dependent options.
Refer to [Writing MooseX-App Plugins](https://metacpan.org/pod/MooseX%3A%3AApp%3A%3AWritingPlugins)
for documentation on how to create your own plugins.
# DEVELOPMENT
Make sure to invoke your script with APP\_DEVELOPER=1 ser during development. This
will come with a starup penalty but perform additional checks for detecting wrong
attribute/type constraint combinations, name clashes, ...
# CAVEATS & KNOWN BUGS
Startup time may be an issue - escpecially if you load many plugins. If you do
not require the functionality of plugins and ability for fine grained
customisation (or Moose for that matter) then you should probably
use [MooX::Options](https://metacpan.org/pod/MooX%3A%3AOptions) or [MooX::Cmd](https://metacpan.org/pod/MooX%3A%3ACmd).
In some cases - especially when using non-standard class inheritance - you may
end up with command classes lacking the help attribute. In this case you need
to include the following line in your base class or command classes.
with qw(MooseX::App::Role::Common);
When manually registering command classes (eg. via app\_command\_register) in
multiple base classes with different sets of plugins (why would you ever want
to do that?), then meta attributes may lack some attribute metaclasses. In
this case you need to load the missing attribute traits explicitly:
option 'argument' => (
depends => 'otherargument',
trait => ['MooseX::App::Plugin::Depends::Meta::Attribute'], # load trait
);
# SEE ALSO
Read the [Tutorial](https://metacpan.org/pod/MooseX%3A%3AApp%3A%3ATutorial) for getting started with a simple
MooseX::App command line application.
For alternatives you can check out
[MooseX::App::Cmd](https://metacpan.org/pod/MooseX%3A%3AApp%3A%3ACmd), [MooseX::Getopt](https://metacpan.org/pod/MooseX%3A%3AGetopt), [MooX::Options](https://metacpan.org/pod/MooX%3A%3AOptions), [MooX::Cmd](https://metacpan.org/pod/MooX%3A%3ACmd) and [App::Cmd](https://metacpan.org/pod/App%3A%3ACmd)
# SUPPORT
Please report any bugs or feature requests via
[https://github.com/maros/MooseX-App/issues/new](https://github.com/maros/MooseX-App/issues/new). I will be notified, and
then you'll automatically be notified of progress on your report as I make
changes.
# AUTHOR
Maroš Kollár
CPAN ID: MAROS
maros [at] k-1.com
http://www.k-1.com
# CONTRIBUTORS
Special thanks to all contributors.
In no particular order: Andrew Jones, George Hartzell, Steve Nolte,
Michael G, Thomas Klausner, Yanick Champoux, Edward Baudrez, David Golden,
J.R. Mash, Thilo Fester, Gregor Herrmann, Sergey Romanov, Sawyer X, Roman F.,
Hunter McMillen, Maik Hentsche, Alexander Stoddard, Marc Logghe, Tina Müller,
Lisa Hare, Jose Luis Martinez, Frank Schreiner, Bernhard M. Wiedemann
You are more than welcome to contribute to MooseX-App. Please have a look
at the [https://github.com/maros/MooseX-App/issues?q=is%3Aissue+is%3Aopen+label%3AWishlist](https://github.com/maros/MooseX-App/issues?q=is%3Aissue+is%3Aopen+label%3AWishlist)
list of open wishlist issues for ideas.
# COPYRIGHT
MooseX::App is Copyright (c) 2012-21 Maroš Kollár.
This library is free software and may be distributed under the same terms as
perl itself. The full text of the licence can be found in the LICENCE file
included with this module.
META.json100644000765000024 545314514737355 14172 0ustar00mkostaff000000000000MooseX-App-1.43{
"abstract" : "Write user-friendly command line apps with even less suffering",
"author" : [
"Maro\u0161 Koll\u00e1r "
],
"dynamic_config" : 0,
"generated_by" : "Dist::Zilla version 6.030, CPAN::Meta::Converter version 2.150010",
"license" : [
"perl_5"
],
"meta-spec" : {
"url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec",
"version" : "2"
},
"name" : "MooseX-App",
"optional_features" : {
"colour" : {
"description" : "Colourful output",
"prereqs" : {
"runtime" : {
"requires" : {
"IO::Interactive" : "0",
"Term::ANSIColor" : "0",
"Win32::Console::ANSI" : "0"
}
}
}
},
"config" : {
"description" : "Config plugins",
"prereqs" : {
"runtime" : {
"requires" : {
"File::HomeDir" : "0"
}
}
}
},
"term" : {
"description" : "Term plugin",
"prereqs" : {
"runtime" : {
"requires" : {
"IO::Interactive" : "0",
"Term::ANSIColor" : "0"
}
}
}
},
"typo" : {
"description" : "Typo plugin",
"prereqs" : {
"runtime" : {
"requires" : {
"Text::WagnerFischer" : "0"
}
}
}
}
},
"prereqs" : {
"configure" : {
"requires" : {
"ExtUtils::MakeMaker" : "0"
}
},
"develop" : {
"requires" : {
"Test::Perl::Critic" : "0",
"Test::Pod" : "1.14",
"Test::Pod::Coverage" : "1.04"
}
},
"runtime" : {
"requires" : {
"Config::Any" : "0",
"File::Basename" : "0",
"File::Spec" : "0",
"List::Util" : "1.44",
"Module::Pluggable" : "0",
"Moose" : "2.00",
"Pod::Elemental" : "0",
"namespace::autoclean" : "0",
"perl" : "5.010"
}
},
"test" : {
"requires" : {
"Test::Most" : "0",
"Test::NoWarnings" : "0"
}
}
},
"release_status" : "stable",
"resources" : {
"bugtracker" : {
"web" : "https://github.com/maros/MooseX-App/issues"
},
"repository" : {
"type" : "git",
"url" : "git://github.com/maros/MooseX-App.git",
"web" : "https://github.com/maros/MooseX-App"
}
},
"version" : "1.43",
"x_generated_by_perl" : "v5.30.3",
"x_serialization_backend" : "JSON::XS version 4.02",
"x_spdx_expression" : "Artistic-1.0-Perl OR GPL-1.0-or-later"
}
t000755000765000024 014514737355 12645 5ustar00mkostaff000000000000MooseX-App-1.4306_env.t100644000765000024 317014514737355 14270 0ustar00mkostaff000000000000MooseX-App-1.43/t# -*- perl -*-
# t/06_plugin_env.t - Test env
use Test::Most tests => 5+1;
use Test::NoWarnings;
use lib 't/testlib';
use Test01;
subtest 'Command with argv' => sub {
MooseX::App::ParsedArgv->new(argv => [qw(command_a --command_local1 11 --global 1)]);
my $test01 = Test01->new_with_command;
isa_ok($test01,'Test01::CommandA');
is($test01->command_local1,'11','Arg from command config');
};
subtest 'Command only with env' => sub {
MooseX::App::ParsedArgv->new(argv => [qw(command_a --global 1)]);
local $ENV{LOCAL1} = 12;
my $test01 = Test01->new_with_command;
isa_ok($test01,'Test01::CommandA');
is($test01->command_local1,'12','Arg from command env');
};
subtest 'Command with env and argv' => sub {
MooseX::App::ParsedArgv->new(argv => [qw(command_a --command_local1 13 --global 1)]);
local $ENV{LOCAL1} = 12;
my $test01 = Test01->new_with_command;
isa_ok($test01,'Test01::CommandA');
is($test01->command_local1,'13','Arg from command argv');
};
subtest 'Env not passing type constraint' => sub {
MooseX::App::ParsedArgv->new(argv => [qw(command_a --global 1)]);
local $ENV{LOCAL1} = 'aa';
my $test01 = Test01->new_with_command;
isa_ok($test01,'MooseX::App::Message::Envelope');
is($test01->blocks->[0]->header,"Invalid environment value for 'LOCAL1'","Message ok");
};
subtest 'Coerce env value' => sub {
MooseX::App::ParsedArgv->new(argv => [qw(command_d --global 1)]);
local $ENV{LOCAL1} = 42;
my $test01 = Test01->new_with_command;
isa_ok($test01,'Test01::CommandD');
is_deeply($test01->command_local1,[42],'Arg coerced from command env');
};00_load.t100755000765000024 601614514737355 14416 0ustar00mkostaff000000000000MooseX-App-1.43/t# -*- perl -*-
# t/00_load.t - check module loading and create testing directory
use Test::Most tests => 43;
use_ok( 'MooseX::App' );
use_ok( 'MooseX::App::ParsedArgv' );
use_ok( 'MooseX::App::Command' );
#use_ok( 'MooseX::App::Role' ); # cannot test since it can only be loaded into a Moose::Role
use_ok( 'MooseX::App::Utils' );
use_ok( 'MooseX::App::Message::Block' );
use_ok( 'MooseX::App::Message::Envelope' );
use_ok( 'MooseX::App::Meta::Role::Attribute::Option' );
use_ok( 'MooseX::App::Meta::Role::Class::Base' );
use_ok( 'MooseX::App::Meta::Role::Class::Command' );
use_ok( 'MooseX::App::Meta::Role::Class::Simple' );
use_ok( 'MooseX::App::Meta::Role::Class::Documentation');
use_ok( 'MooseX::App::Plugin::BashCompletion' );
use_ok( 'MooseX::App::Plugin::BashCompletion::Command');
use_ok( 'MooseX::App::Plugin::BashCompletion::Meta::Class');
use_ok( 'MooseX::App::Plugin::Config' );
use_ok( 'MooseX::App::Plugin::Config::Meta::Class');
use_ok( 'MooseX::App::Plugin::Version' );
use_ok( 'MooseX::App::Plugin::Version::Command');
use_ok( 'MooseX::App::Plugin::Version::Meta::Class');
use_ok( 'MooseX::App::Plugin::Man' );
use_ok( 'MooseX::App::Plugin::Man::Command');
use_ok( 'MooseX::App::Plugin::Man::Meta::Class');
use_ok( 'MooseX::App::Plugin::Depends' );
use_ok( 'MooseX::App::Plugin::Depends::Meta::Attribute');
use_ok( 'MooseX::App::Plugin::Depends::Meta::Class');
use_ok( 'MooseX::App::Plugin::MutexGroup' );
use_ok( 'MooseX::App::Plugin::MutexGroup::Meta::Attribute');
use_ok( 'MooseX::App::Plugin::MutexGroup::Meta::Class');
use_ok( 'MooseX::App::Utils');
use_ok( 'MooseX::App::Simple');
use_ok( 'MooseX::App::Exporter');
use_ok( 'MooseX::App::Role::Base');
use_ok( 'MooseX::App::Role::Common');
SKIP :{
my $ok = eval {
Class::Load::load_class('Term::ReadKey');
Class::Load::load_class('IO::Interactive');
use_ok( 'MooseX::App::Plugin::Term' );
use_ok( 'MooseX::App::Plugin::Term::Meta::Class');
use_ok( 'MooseX::App::Plugin::Term::Meta::Attribute');
};
unless ($ok) {
skip "Term::ReadKey and/or IO::Interactive are not installed",3;
}
}
SKIP :{
my $ok = eval {
Class::Load::load_class('Term::ANSIColor');
Class::Load::load_class('IO::Interactive');
use_ok( 'MooseX::App::Plugin::Color' );
use_ok( 'MooseX::App::Message::BlockColor' );
use_ok( 'MooseX::App::Plugin::Color::Meta::Class');
};
unless ($ok) {
skip "Term::ANSIColor and/or IO::Interactive are not installed",3;
}
}
SKIP :{
my $ok = eval {
Class::Load::load_class('File::HomeDir');
use_ok( 'MooseX::App::Plugin::ConfigHome' );
use_ok( 'MooseX::App::Plugin::ConfigHome::Meta::Class');
};
unless ($ok) {
skip "File::HomeDir is not installed",2;
}
}
SKIP :{
my $ok = eval {
Class::Load::load_class('Text::WagnerFischer');
use_ok( 'MooseX::App::Plugin::Typo' );
use_ok( 'MooseX::App::Plugin::Typo::Meta::Class');
};
unless ($ok) {
skip "Text::WagnerFischer is not installed",2;
}
}02_meta.t100644000765000024 624014514737355 14423 0ustar00mkostaff000000000000MooseX-App-1.43/t# -*- perl -*-
# t/02_meta.t - MOP tests
use Test::Most tests => 28+1;
use Test::NoWarnings;
use lib 't/testlib';
use Test01;
my $meta = Test01->meta;
my $commands = $meta->app_commands;
is(join(',',sort keys %{$commands}),'command_a,command_b,command_c1,command_d','Commands found');
is(join(',',sort values %{$commands}),'Test01::CommandA,Test01::CommandB,Test01::CommandC1,Test01::CommandD','Commands found');
cmp_deeply($meta->app_namespace,[qw(Test01)],'Command namespace ok');
is($meta->app_base,'02_meta.t','Command base ok');
is($meta->app_messageclass,'MooseX::App::Message::Block','Message class');
ok(Test01->can('new_with_command'),'Role applied to base class');
ok(Test01->can('initialize_command_class'),'Role applied to base class');
is(scalar keys %{$commands},4,'Found three commands');
is($commands->{command_a},'Test01::CommandA','Command A found');
is($meta->command_find('COMMAND_a'),'command_a','Command A matched');
cmp_deeply($meta->command_candidates('COmmand'),['command_a','command_b','command_c1','command_d'],'Command A,B,C1 and D matched');
cmp_deeply($meta->command_candidates('command_C'),['command_c1'],'Command C1 matched fuzzy');
is($meta->command_candidates('command_c1'),'command_c1','Command C1 matched exactly');
my @attributes = $meta->command_usage_attributes;
is(scalar(@attributes),3,'Has three attributes');
is($attributes[0]->cmd_usage_name,'--global','Usage name ok');
is($attributes[0]->cmd_usage_description,'test [Required; Integer; Important!]','Usage description ok');
is($attributes[1]->cmd_usage_name,'--config','Usage name ok');
is($attributes[2]->cmd_usage_name,'--help -h --usage -?','Usage name ok');
is($attributes[2]->cmd_usage_description,'Prints this usage information. [Flag]','Usage description ok');
my $meta_attribute = $meta->find_attribute_by_name('global');
is(join(',',$meta_attribute->cmd_tags_list($meta_attribute)),'Required,Integer,Important!','Tags ok');
$meta_attribute->cmd_tags(['Use with care']);
is(join(',',$meta_attribute->cmd_tags_list()),'Required,Integer,Use with care','Changed tags ok');
require Test01::CommandA;
my $description = $meta->command_usage_description(Test01::CommandA->meta);
isa_ok($description,'MooseX::App::Message::Block');
like($description->body,qr/varius nec iaculis vitae/,'Description body ok');
require Test01::CommandB;
is(Test01::CommandB->meta->command_short_description,'Test class command B for test 01','Pod short description parsed ok');
is(Test01::CommandB->meta->command_long_description,'Some description of *command B*
some code
some code
SUB HEADLINE
some more desc
* item 1
* item 2
* item 2.1
* item 2.2
hase ist so super and this is a very long sentence witch breaks after i have written some bla bla.
another interesting paragraph.','Pod long description parsed ok');
require Test01::CommandC1;
is(Test01::CommandB->meta->command_usage,'use with care','Command usage parsed ok');
is(Test01::CommandC1->meta->find_attribute_by_name('param_internal_name')->cmd_name_primary,'external_name','Attribute name ok');
is(join(',',Test01::CommandB->meta->find_attribute_by_name('param_b')->cmd_tags_list),'Required,Possible values: aaa, bbb, ccc, ddd, eee, fff','Check attributes tags');config.pl100644000765000024 23214514737355 14564 0ustar00mkostaff000000000000MooseX-App-1.43/t{
global => {
global => 123,
},
command_a => {
global => 234,
command_local1 => 22,
},
}Makefile.PL100644000765000024 272414514737355 14521 0ustar00mkostaff000000000000MooseX-App-1.43# This file was automatically generated by Dist::Zilla::Plugin::MakeMaker v6.030.
use strict;
use warnings;
use 5.010;
use ExtUtils::MakeMaker;
my %WriteMakefileArgs = (
"ABSTRACT" => "Write user-friendly command line apps with even less suffering",
"AUTHOR" => "Maro\x{161} Koll\x{e1}r ",
"CONFIGURE_REQUIRES" => {
"ExtUtils::MakeMaker" => 0
},
"DISTNAME" => "MooseX-App",
"LICENSE" => "perl",
"MIN_PERL_VERSION" => "5.010",
"NAME" => "MooseX::App",
"PREREQ_PM" => {
"Config::Any" => 0,
"File::Basename" => 0,
"File::Spec" => 0,
"List::Util" => "1.44",
"Module::Pluggable" => 0,
"Moose" => "2.00",
"Pod::Elemental" => 0,
"namespace::autoclean" => 0
},
"TEST_REQUIRES" => {
"Test::Most" => 0,
"Test::NoWarnings" => 0
},
"VERSION" => "1.43",
"test" => {
"TESTS" => "t/*.t"
}
);
my %FallbackPrereqs = (
"Config::Any" => 0,
"File::Basename" => 0,
"File::Spec" => 0,
"List::Util" => "1.44",
"Module::Pluggable" => 0,
"Moose" => "2.00",
"Pod::Elemental" => 0,
"Test::Most" => 0,
"Test::NoWarnings" => 0,
"namespace::autoclean" => 0
);
unless ( eval { ExtUtils::MakeMaker->VERSION(6.63_03) } ) {
delete $WriteMakefileArgs{TEST_REQUIRES};
delete $WriteMakefileArgs{BUILD_REQUIRES};
$WriteMakefileArgs{PREREQ_PM} = \%FallbackPrereqs;
}
delete $WriteMakefileArgs{CONFIGURE_REQUIRES}
unless eval { ExtUtils::MakeMaker->VERSION(6.52) };
WriteMakefile(%WriteMakefileArgs);
meta000755000765000024 014514737355 13330 5ustar00mkostaff000000000000MooseX-App-1.43argv.pl100755000765000024 40614514737355 14747 0ustar00mkostaff000000000000MooseX-App-1.43/meta#!/usr/bin/env perl
use strict;
use warnings;
use 5.010;
use FindBin qw();
use lib ("$FindBin::Bin/../lib");
use MooseX::App::ParsedArgv;
use Data::Dumper;
my $inst = MooseX::App::ParsedArgv->instance();
say Dumper($inst);
$inst->options;
say Dumper($inst);
01_basic.t100755000765000024 1336114514737355 14602 0ustar00mkostaff000000000000MooseX-App-1.43/t# -*- perl -*-
# t/01_basic.t - Basic tests
use Test::Most tests => 12+1;
use Test::NoWarnings;
use FindBin qw();
use lib 't/testlib';
use Test01;
subtest 'Excact command with option' => sub {
MooseX::App::ParsedArgv->new(argv => [qw(command_a --global 10)]);
my $test01 = Test01->new_with_command();
isa_ok($test01,'Test01::CommandA');
is($test01->global,10,'Param is set');
};
subtest 'Fuzzy command with option' => sub {
my $test02 = Test01->new_with_command( ARGV => [qw(Command_A --globa 11)]);
isa_ok($test02,'Test01::CommandA');
is($test02->global,11,'Param is set');
};
subtest 'Wrong command' => sub {
MooseX::App::ParsedArgv->new(argv => [qw(xxxx --global 10)]);
my $test03 = Test01->new_with_command;
isa_ok($test03,'MooseX::App::Message::Envelope');
is($test03->blocks->[0]->header,"Unknown command 'xxxx'",'Message is set');
is($test03->blocks->[0]->type,"error",'Message is of type error');
is($test03->blocks->[1]->header,"usage:",'Usage set');
is($test03->blocks->[1]->body," 01_basic.t [long options...]
01_basic.t help
01_basic.t --help",'Usage body set');
is($test03->blocks->[3]->header,"global options:",'Global options set');
is($test03->blocks->[3]->body," --global test [Required; Integer; Important!]
--config Path to command config file
--help -h --usage -? Prints this usage information. [Flag]",'Global options body set');
is($test03->blocks->[4]->header,"available commands:",'Available commands set');
is($test03->blocks->[4]->body," command_a Command A!
command_b Test class command B for test 01
command_c1 Test C1
command_d Command A!
help Prints this usage information",'Available commands body set');
};
subtest 'Help for command' => sub {
MooseX::App::ParsedArgv->new(argv => [qw(command_a --help)]);
my $test04 = Test01->new_with_command;
isa_ok($test04,'MooseX::App::Message::Envelope');
is($test04->blocks->[0]->header,"usage:",'Usage is set');
is($test04->blocks->[0]->body," 01_basic.t command_a [long options...]
01_basic.t help
01_basic.t command_a --help",'Usage body set');
is($test04->blocks->[1]->header,"description:",'Description is set');
is($test04->blocks->[1]->body," Lorem ipsum dolor sit amet, consectetur adipiscing elit. Cras dui velit,
varius nec iaculis vitae, elementum eget mi.
* bullet1
* bullet2
* bullet3
Cras eget mi nisi. In hac habitasse platea dictumst.",'Description body set');
is($test04->blocks->[2]->header,"options:",'Options header is set');
is($test04->blocks->[2]->body," --global test [Required; Integer; Important!]
--command_local1 some docs about the long texts that seem to occur
randomly [Integer; Env: LOCAL1; Important]
--command_local2 Verylongwordwithoutwhitespacestotestiftextformating
worksproperly [Env: LOCAL2]
--config Path to command config file
--help -h --usage -? Prints this usage information. [Flag]",'Options body is set');
};
subtest 'With extra args' => sub {
MooseX::App::ParsedArgv->new(argv => [qw(Command_b --global 10 --param_b aaa)]);
my $test02 = Test01->new_with_command( 'param_b' => 'bbb', 'global' => 20, 'private'=>5 );
isa_ok($test02,'Test01::CommandB');
is($test02->global,20,'Param global is set');
is($test02->param_b,'bbb','Param param_b is set');
is($test02->private,5,'Param private is set');
};
subtest 'Wrapper script' => sub {
my $output = `$^X $FindBin::Bin/example/test01.pl command_a --command_local2 test --global 10`;
is($output,'RUN COMMAND-A:test','Output is ok');
};
subtest 'Custom help text' => sub {
MooseX::App::ParsedArgv->new(argv => [qw(command_b --help)]);
my $test06 = Test01->new_with_command;
isa_ok($test06,'MooseX::App::Message::Envelope');
is($test06->blocks->[0]->header,"usage:",'Usage is set');
is($test06->blocks->[0]->body," use with care",'Usage is ok');
is($test06->blocks->[1]->header,"description:",'description is set');
like($test06->blocks->[1]->body,qr/ Some description of \*command B\*/,'Description is ok');
};
subtest 'Input errors missing' => sub {
MooseX::App::ParsedArgv->new(argv => [qw(command_a --command_local1)]);
my $test07 = Test01->new_with_command;
isa_ok($test07,'MooseX::App::Message::Envelope');
is($test07->blocks->[0]->header,"Missing value for 'command_local1'",'Error message ok');
};
subtest 'Input errors type' => sub {
MooseX::App::ParsedArgv->new(argv => [qw(command_a --command_local1 sss)]);
my $test08 = Test01->new_with_command;
isa_ok($test08,'MooseX::App::Message::Envelope');
is($test08->blocks->[0]->header,"Invalid value for 'command_local1'",'Error message ok');
is($test08->blocks->[0]->body,"Value must be an integer (not 'sss')",'Error message ok');
};
subtest 'Global help requested' => sub {
MooseX::App::ParsedArgv->new(argv => [qw(help)]);
my $test09 = Test01->new_with_command;
isa_ok($test09,'MooseX::App::Message::Envelope');
like($test09->blocks->[0]->body,qr/ 01_basic\.t \[long options\.\.\.\]/,'Help message ok');
};
subtest 'Missing command' => sub {
MooseX::App::ParsedArgv->new(argv => []);
my $test10 = Test01->new_with_command;
isa_ok($test10,'MooseX::App::Message::Envelope');
is($test10->blocks->[0]->header,'Missing command','Error message ok');
};
subtest 'Extra params' => sub {
MooseX::App::ParsedArgv->new(argv => [qw(command_a something else)]);
my $test11 = Test01->new_with_command;
isa_ok($test11,'MooseX::App::Message::Envelope');
is($test11->blocks->[0]->header,"Unknown parameter 'else'",'Error message ok');
};
03_utils.t100755000765000024 756114514737355 14650 0ustar00mkostaff000000000000MooseX-App-1.43/t# -*- perl -*-
# t/03_utils.t
use Test::Most tests => 4+1;
use Test::NoWarnings;
use MooseX::App::Utils;
use MooseX::App::ParsedArgv;
subtest 'Class to command' => sub {
is(MooseX::App::Utils::class_to_command('Command'),'command','Command ok');
is(MooseX::App::Utils::class_to_command('CommandSuper'),'command_super','Command ok');
is(MooseX::App::Utils::class_to_command('CommandBA'),'command_ba','Command ok');
is(MooseX::App::Utils::class_to_command('CommandBA12'),'command_ba12','Command ok');
is(MooseX::App::Utils::class_to_command('CommandBALow'),'command_ba_low','Command ok');
};
subtest 'Format text' => sub {
is(
MooseX::App::Utils::format_text('Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec vitae lectus purus, quis dapibus orci. Proin mollis est in nisl congue vel ornare felis imperdiet.'),
' Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec vitae
lectus purus, quis dapibus orci. Proin mollis est in nisl congue vel
ornare felis imperdiet.',
'Format text ok');
is(
MooseX::App::Utils::format_text('Loremipsumdolorsitamet,consecteturadipiscingelit.Namegetarcunecdolorbibendumblanditsitametnonipsum.'),
' Loremipsumdolorsitamet,consecteturadipiscingelit.
Namegetarcunecdolorbibendumblanditsitametnonipsum.',
'Format text ok');
is(
MooseX::App::Utils::format_text('LoremipsumdolorsitametconsecteturadipiscingelitNamegetarcunecdolorbibendumblanditsitametnonipsum.'),
' LoremipsumdolorsitametconsecteturadipiscingelitNamegetarcunecdolorbibendum
blanditsitametnonipsum.',
'Format text ok');
};
subtest 'Formater' => sub {
my $list = MooseX::App::Utils::format_list(
['part1','Lorem ipsum dolor sit amet, consectetur adipiscing elit. vitae lectus purus, quis dapibus orci.'],
['part2_something','Lorem ipsum dolor sit amet, consectetur adipiscing elit.'],
['part3',''],
);
is(
$list,
' part1 Lorem ipsum dolor sit amet, consectetur adipiscing elit.
vitae lectus purus, quis dapibus orci.
part2_something Lorem ipsum dolor sit amet, consectetur adipiscing elit.
part3 ',
'Format list ok'
);
};
subtest 'Parser' => sub {
my $parser = MooseX::App::ParsedArgv->new({
argv => ['hello','--bool','mellow','-hui','--help','--help','--test','1','baer','--test','2','--xxx','x1','x2','--key=value1','--key=value2','-u','--','hase','--luchs'],
hints_novalue => ['bool'],
hints_permute => ['xxx'],
});
is(scalar(@{$parser->elements}),13,'Has 13 elements');
is($parser->elements->[0]->key,'hello','Parameter parsed ok');
is($parser->elements->[0]->type,'parameter','Parameter type ok');
is($parser->elements->[1]->key,'bool','Flag parsed ok');
is($parser->elements->[1]->type,'option','Flag type ok');
is($parser->elements->[2]->key,'mellow','Parameter parsed ok');
is($parser->elements->[3]->key,'h','Flag parsed ok');
is($parser->elements->[4]->key,'u','Flag parsed ok');
is($parser->elements->[5]->key,'i','Flag parsed ok');
is($parser->elements->[6]->key,'help','Flag parsed ok');
is($parser->elements->[7]->key,'test','Option parsed ok');
cmp_deeply([$parser->elements->[7]->all_scalar_values],[1,2], 'Option value ok');
is($parser->elements->[8]->key,'baer','Parameter parsed ok');
is($parser->elements->[9]->key,'xxx','Parameter parsed ok');
cmp_deeply([$parser->elements->[9]->all_scalar_values],['x1','x2'],'Option value ok');
is($parser->elements->[10]->key,'key','Option parsed ok');
is($parser->elements->[10]->key,'key','Extra parsed ok');
cmp_deeply([$parser->elements->[10]->all_scalar_values],['value1','value2'],'Option value ok');
is($parser->elements->[11]->key,'hase','Extra parsed ok');
is($parser->elements->[12]->key,'--luchs','Extra parsed ok');
};
14_gh_45.t100644000765000024 341214514737355 14404 0ustar00mkostaff000000000000MooseX-App-1.43/t# -*- perl -*-
# t/14_gh_45.t - Boolean negation
use Test::Most tests => 3+1;
use Test::NoWarnings;
use lib 't/testlib';
{
package Test14;
use MooseX::App::Simple;
option 'b1' => (
is => 'rw',
isa => 'Bool',
cmd_negate => ['not-b1']
);
option 'not_b1' => (
is => 'rw',
isa => 'Bool',
);
option 'b2yes' => (
is => 'rw',
isa => 'Bool',
cmd_negate => ['no_b2','unb2']
);
sub run {
my ($self) = @_;
return "ok";
}
}
subtest 'boolean negation' => sub {
plan tests => 4;
Test14->meta->app_fuzzy(0);
{
MooseX::App::ParsedArgv->new(argv => [qw(--not-b1 --not_b1 --b2yes)]);
my $test01 = Test14->new_with_options();
isa_ok($test01,'Test14');
is($test01->b1,0,'Did not set b1');
is($test01->not_b1,1,'Did set not_b1');
is($test01->b2yes,1,'Did set b2');
}
};
subtest 'boolean fuzzy negation' => sub {
plan tests => 4;
Test14->meta->app_fuzzy(1);
{
MooseX::App::ParsedArgv->new(argv => [qw(--not-b --not_b --b2)]);
my $test01 = Test14->new_with_options();
isa_ok($test01,'Test14');
is($test01->b1,0,'Did not set b1');
is($test01->not_b1,1,'Did set not_b1');
is($test01->b2yes,1,'Did set b2');
}
};
subtest 'ambiguous negation' => sub {
plan tests => 3;
Test14->meta->app_fuzzy(1);
{
MooseX::App::ParsedArgv->new(argv => [qw(--not-b1 --b1 --b2yes --no_b2 --unb2 --b2 --un)]);
my $test01 = Test14->new_with_options();
isa_ok($test01,'Test14');
is($test01->b1,1,'Did set b1');
is($test01->b2yes,0,'Did not set b2');
}
};07_single.t100644000765000024 201014514737355 14752 0ustar00mkostaff000000000000MooseX-App-1.43/t# -*- perl -*-
# t/07_single.t- Test MooseX::App::Single
use Test::Most tests => 3+1;
use Test::NoWarnings;
use lib 't/testlib';
use Test05;
subtest 'Single command' => sub {
MooseX::App::ParsedArgv->new(argv => [qw()]);
my $test05 = Test05->new_with_options;
isa_ok($test05,'MooseX::App::Message::Envelope');
is($test05->blocks->[0]->header,"Required option 'another_option' missing","Check for error message");
};
subtest 'Single command' => sub {
MooseX::App::ParsedArgv->new(argv => [qw(--another_option 123)]);
my $test05 = Test05->new_with_options({ some_option => 1 });
isa_ok($test05,'Test05');
is($test05->another_option,'123','Arg from command ARGV');
is($test05->some_option,1,'Arg from new_with_options');
};
subtest 'Single command help' => sub {
MooseX::App::ParsedArgv->new(argv => [qw(--help)]);
my $test05 = Test05->new_with_options();
isa_ok($test05,'MooseX::App::Message::Envelope');
is($test05->blocks->[0]->header,"usage:","Usage header is first");
};
podstyle.t100644000765000024 175514514737355 15235 0ustar00mkostaff000000000000MooseX-App-1.43/xt# -*- perl -*-
use strict;
use warnings;
use Test::More;
eval "use Pod::Simple::SimpleTree";
plan skip_all => 'Pod::Simple::SimpleTree required' if $@;
eval "use Test::Pod";
plan skip_all => 'Test::Pod required' if $@;
plan skip_all => 'set TEST_AUTHOR to enable this test' unless $ENV{TEST_AUTHOR};
my @files;
foreach (all_pod_files()) {
next if /Schema\//;
next if /\.pl$/;
push @files,$_;
}
my @required_heads=qw(NAME SYNOPSIS DESCRIPTION METHODS AUTHOR);
plan tests => scalar @files * scalar @required_heads;
foreach my $file (@files) {
my $parser=Pod::Simple::SimpleTree->new;
$parser->accept_targets('*');
my $root=$parser->parse_file($file)->root;
shift(@$root);shift(@$root);
my @heads;
my %heads;
foreach my $node (@$root) {
next unless $node->[0] eq 'head1';
push(@heads,$node->[2]);
$heads{$node->[2]}=1;
}
foreach my $heading (@required_heads) {
ok($heads{$heading},"$file has $heading");
}
}
09_classes.t100644000765000024 502714514737355 15143 0ustar00mkostaff000000000000MooseX-App-1.43/t# -*- perl -*-
# t/09_classes.t - Test classes
use Test::Most tests => 6+1;
use Test::NoWarnings;
use lib 't/testlib';
use Test04;
use Test03;
subtest 'Extend base class' => sub {
MooseX::App::ParsedArgv->new(argv => [qw()]);
my $test01 = Test04->new_with_command;
isa_ok($test01,'MooseX::App::Message::Envelope');
like($test01->blocks->[2]->body,qr/--test1\s+\[Integer\]/,'--test1 included');
like($test01->blocks->[2]->body,qr/--test2\s+\[Flag\]/,'--test2 included');
unlike($test01->blocks->[2]->body,qr/--test3/,'--test3 not included');
};
subtest 'Wrong usage' => sub {
throws_ok { Test03->new->new_with_command } qr/new_with_command is a class method/, 'Only callable as class method';
use Test03::SomeCommand;
throws_ok { Test03::SomeCommand->new_with_command } qr/new_with_command may only be called from the application base package/, 'new_with_command may only be called from the application base package';
throws_ok { Test03->new_with_command(1,2,3) } qr/new_with_command got invalid extra arguments/, 'Wrong default args';
};
subtest 'Conflicts' => sub {
MooseX::App::ParsedArgv->new(argv => [qw(broken --conflict a)]);
throws_ok {
Test03->new_with_command;
} qr/Command line option conflict/, 'Conflict detected';
};
subtest 'Default args available with extra inheritance' => sub {
MooseX::App::ParsedArgv->new(argv => [qw(yetanothercommand --help)]);
my $another = Test03->new_with_command;
isa_ok($another,'MooseX::App::Message::Envelope');
like($another->blocks->[0]->body,qr/test03\syetanothercommand/,'Help ok');
is($another->blocks->[0]->header,'usage:','Help ok');
MooseX::App::ParsedArgv->new(argv => [qw(yetanothercommand -ab --bool3)]);
my $yetanother = Test03->new_with_command(private => 'test');
isa_ok($yetanother,'Test03::YetAnotherCommand');
is($yetanother->private,'test','Option has been passed on');
};
subtest 'Attributes from role' => sub {
MooseX::App::ParsedArgv->new(argv => [qw(somecommand --roleattr a --another b)]);
my $test03 = Test03->new_with_command();
isa_ok($test03,'Test03::SomeCommand');
is($test03->roleattr,'a','Attribute from role ok');
};
subtest 'Correct order from role ' => sub {
MooseX::App::ParsedArgv->new(argv => [qw(somecommand a1 b2 ccc --another b)]);
my $test03 = Test03->new_with_command;
isa_ok($test03,'Test03::SomeCommand');
is($test03->param_c,'a1','First from role');
is($test03->param_a,'b2','Second from role');
is($test03->param_b,'ccc','Third from role');
};
11_process.t100644000765000024 647214514737355 15162 0ustar00mkostaff000000000000MooseX-App-1.43/t# -*- perl -*-
# t/11_process.t - Test via subprocesses
use Test::Most tests => 1+1;
use Test::NoWarnings;
use FindBin qw();
use IPC::Open3 qw(open3);
use Symbol qw(gensym);
my $BASE = "$^X $FindBin::Bin/example";
subtest 'Test basic exit codes' => sub {
SKIP: {
skip "Cannot test on MSWin",7
if $^O =~ /^MSWin/;
skip "Cannot test on *BSD",7
if $^O =~ /bsd$/;
test_subprocess(
bin => 'test02.pl',
exit => 127,
out => '',
err => qr/Missing command/,
);
test_subprocess(
bin => 'test02.pl error',
exit => 25,
err => qr/XXX/,
);
test_subprocess(
bin => 'test02.pl version',
exit => 0,
out => qr/VERSION/,
err => '',
);
test_subprocess(
bin => 'test02.pl version',
exit => 0,
out => qr/VERSION/,
err => '',
);
test_subprocess(
bin => 'test02.pl record --help',
exit => 0,
out => qr/usage:/,
err => '',
);
test_subprocess(
bin => 'test02.pl record',
exit => 0,
out => qr/RAN/,
err => '',
);
test_subprocess(
bin => 'test02.pl record --notthere',
exit => 1,
out => '',
err => qr/Unknown option 'notthere'/,
);
}
};
sub test_subprocess {
my (%params) = @_;
$params{args} ||= [];
my($in_fh, $out_fh, $err_fh, $out, $err, $pid, $exit);
eval {
# Set timeout
local $SIG{ALRM} = sub { die('timeout') };
alarm(3);
$err_fh = gensym();
$pid = open3(
$in_fh, $out_fh, $err_fh,
$BASE.'/'.$params{bin},
);
if (defined $pid) {
waitpid($pid,0);
$pid = undef;
$exit = $? >> 8;
$out = '';
while(<$out_fh>) {
$out .= $_;
}
$err = '';
while(<$err_fh>) {
$err .= $_;
}
# Compare exitcode
if (exists $params{exit}) {
is($exit,$params{exit},'Exitcode '.$params{bin}.' ok');
}
# Comare STDOUT
if (exists $params{out}) {
if (ref $params{out} eq 'Regexp') {
like($out,$params{out},'Output '.$params{bin}.' ok');
} else {
is($out,$params{out},'Output '.$params{bin}.' ok');
}
}
# Compare STDERR
if (exists $params{err}) {
if (ref $params{err} eq 'Regexp') {
like($err,$params{err},'Error '.$params{bin}.' ok');
} else {
is($err,$params{err},'Error '.$params{bin}.' ok');
}
}
} else {
fail('Could not start process :'.$!);
}
};
alarm(0);
kill 'KILL', $pid
if defined $pid;
if ($@ ) {
# Kill pid if still there
fail('Error running '.$params{bin}.' :'.($@ || 'unknown'));
return;
}
return;
}05_extended.t100755000765000024 3032414514737355 15323 0ustar00mkostaff000000000000MooseX-App-1.43/t# -*- perl -*-
# t/05_extended.t - Extended tests
use Test::Most tests => 29+1;
use Test::NoWarnings;
use FindBin qw();
use lib 't/testlib';
use Test03;
Test03->meta->app_fuzzy(0);
Test03->meta->app_strict(1);
subtest 'Non-Fuzzy command matching' => sub {
MooseX::App::ParsedArgv->new(argv => [qw(some --private 1)]);
my $test01 = Test03->new_with_command;
isa_ok($test01,'MooseX::App::Message::Envelope');
is($test01->blocks->[0]->header,"Unknown command 'some'","Message ok");
};
subtest 'Non-Fuzzy attribute matching' => sub {
MooseX::App::ParsedArgv->new(argv => [qw(somecommand --private 1)]);
my $test01 = Test03->new_with_command;
isa_ok($test01,'MooseX::App::Message::Envelope');
is($test01->blocks->[0]->header,"Unknown option 'private'","Message ok");
};
Test03->meta->app_fuzzy(1);
subtest 'Private option is not exposed' => sub {
MooseX::App::ParsedArgv->new(argv => [qw(some --private 1)]);
my $test01 = Test03->new_with_command;
isa_ok($test01,'MooseX::App::Message::Envelope');
is($test01->blocks->[0]->header,"Unknown option 'private'","Message ok");
is($test01->blocks->[0]->type,"error",'Message is of type error');
};
subtest 'Options from role' => sub {
MooseX::App::ParsedArgv->new(argv => [qw(some --another 10 --role 15)]);
my $test02 = Test03->new_with_command;
isa_ok($test02,'Test03::SomeCommand');
is($test02->another_option,'10','Param is set');
is($test02->roleattr,'15','Role param is set');
};
subtest 'Missing attribute value' => sub {
MooseX::App::ParsedArgv->new(argv => [qw(some --another)]);
my $test03 = Test03->new_with_command;
isa_ok($test03,'MooseX::App::Message::Envelope');
is($test03->blocks->[0]->header,"Missing value for 'another'","Message ok");
is($test03->blocks->[0]->type,"error",'Message is of type error');
};
subtest 'All options available & no description' => sub {
MooseX::App::ParsedArgv->new(argv => [qw(some --help)]);
my $test04 = Test03->new_with_command;
isa_ok($test04,'MooseX::App::Message::Envelope');
is($test04->blocks->[2]->header,'options:','No description');
is($test04->blocks->[2]->body," --global_option Enable this to do fancy stuff [Flag]
--roleattr [Role]
--some_option Very important option!
--another [Required; Not important]
--list [Multiple]
--help -h --usage -? Prints this usage information. [Flag]","Message ok");
};
# Not working on cpan testers
#subtest 'Test wrapper script encoding' => sub {
# my $output = `LANG=en_US.UTF-8 $^X $FindBin::Bin/example/test03.pl some_command --another töst\\ möre --some_option "anöther täst"`;
# is($output,'RUN:anöther täst:töst möre','Encoded output');
#}
subtest 'Test type constraints integer' => sub {
MooseX::App::ParsedArgv->new(argv => [qw(another --int 1a)]);
my $test05 = Test03->new_with_command;
isa_ok($test05,'MooseX::App::Message::Envelope');
is($test05->blocks->[0]->header,"Invalid value for 'integer'","Message ok");
};
subtest 'Test type constraints hash' => sub {
MooseX::App::ParsedArgv->new(argv => [qw(another --hash xx)]);
my $test06 = Test03->new_with_command;
isa_ok($test06,'MooseX::App::Message::Envelope');
is($test06->blocks->[0]->header,"Invalid value for 'hash'","Message ok");
};
subtest 'Test type constraints number' => sub {
MooseX::App::ParsedArgv->new(argv => [qw(another --number 2a)]);
my $test07 = Test03->new_with_command;
isa_ok($test07,'MooseX::App::Message::Envelope');
is($test07->blocks->[0]->header,"Invalid value for 'number'","Message ok");
};
subtest 'Test type constraints custom1' => sub {
MooseX::App::ParsedArgv->new(argv => [qw(another --custom1 9)]);
my $test08 = Test03->new_with_command;
isa_ok($test08,'MooseX::App::Message::Envelope');
is($test08->blocks->[0]->header,"Invalid value for 'custom1'","Message ok");
};
subtest 'Test pass type constraints' => sub {
MooseX::App::ParsedArgv->new(argv => [qw(another --hash key1=value1 --split a;b --split c --hash key2=value2 --integer 10 --number 10.10 --custom1 11 --custom2 test --extra1 wurtsch --count --count --cou)]);
my $test09 = Test03->new_with_command;
isa_ok($test09,'Test03::AnotherCommand');
is($test09->hash->{key1},"value1","Hash ok");
is($test09->hash->{key2},"value2","Hash ok");
is($test09->integer,10,"Integer ok");
is($test09->custom1,11,"Custom type 1 ok");
is(ref($test09->custom2),'SCALAR',"Custom type 2 ok");
is(${$test09->custom2},'test',"Custom type 2 ok");
is($test09->extra1,'wurtsch',"Attr set ok");
is($test09->count,3,"Count set ok");
cmp_deeply($test09->split,[qw(a b c)],'Split ok');
};
subtest 'Test ambiguous options' => sub {
MooseX::App::ParsedArgv->new(argv => [qw(another --custom 1 --custom 2)]);
my $test10 = Test03->new_with_command;
isa_ok($test10,'MooseX::App::Message::Envelope');
is($test10->blocks->[0]->header,"Ambiguous option 'custom'","Message ok");
like($test10->blocks->[0]->body,qr/Could be
custom1
custom2/,"Message ok");
};
subtest 'Test flags & defaults' => sub {
MooseX::App::ParsedArgv->new(argv => [qw(yet --bool3)]);
my $test11 = Test03->new_with_command;
isa_ok($test11,'Test03::YetAnotherCommand');
is($test11->bool1,undef,'Bool1 flag is undef');
is($test11->bool2,1,'Bool2 flag is set');
is($test11->bool3,1,'Bool3 flag is set');
is($test11->value,'hase','Value is default');
};
subtest 'Test more flags & defaults' => sub {
MooseX::App::ParsedArgv->new(argv => [qw(yet --bool3 -ab --value baer)]);
my $test11 = Test03->new_with_command;
isa_ok($test11,'Test03::YetAnotherCommand');
is($test11->bool1,1,'Bool1 flag is undef');
is($test11->bool2,1,'Bool2 flag is unset');
is($test11->bool3,1,'Bool3 flag is set');
is($test11->value,'baer','Value is set');
};
subtest 'Test Negate boolean options' => sub {
MooseX::App::ParsedArgv->new(argv => [qw(yet --no-bool3)]);
my $test11 = Test03->new_with_command;
isa_ok($test11,'Test03::YetAnotherCommand');
is($test11->bool3,0,'Bool3 flag is negated');
};
subtest 'Test positional params' => sub {
MooseX::App::ParsedArgv->new(argv => [qw(extra hui --value baer)]);
my $test12 = Test03->new_with_command;
isa_ok($test12,'Test03::ExtraCommand');
is($test12->extra1,'hui','Extra1 value is "hui"');
is($test12->extra2, undef,'Extra2 value is undef');
is($test12->alpha, undef,'alpha value is undef');
is($test12->value,'baer','Value is set');
};
subtest 'Test positional params' => sub {
MooseX::App::ParsedArgv->new(argv => [qw(extra --value baer hui)]);
my $test12 = Test03->new_with_command;
isa_ok($test12,'Test03::ExtraCommand');
is($test12->extra1,'hui','Extra1 value is "hui"');
is($test12->extra2, undef,'Extra2 value is undef');
is($test12->alpha, undef,'alpha value is undef');
is($test12->value,'baer','Value is set');
};
subtest 'Test optional positional params' => sub {
MooseX::App::ParsedArgv->new(argv => [qw(extra hui 11 --value baer)]);
my $test12 = Test03->new_with_command;
isa_ok($test12,'Test03::ExtraCommand');
is($test12->extra1,'hui','Extra1 value is "hui"');
is($test12->extra2,11,'Extra2 value is "11"');
is($test12->alpha, undef,'alpha value is undef');
is($test12->value,'baer','Value is set');
};
subtest 'Test wrong positional params' => sub {
MooseX::App::ParsedArgv->new(argv => [qw(extra hui aa --value baer)]);
my $test13 = Test03->new_with_command;
isa_ok($test13,'MooseX::App::Message::Envelope');
is($test13->blocks->[0]->header,"Invalid value for 'extra2'","Error message ok");
is($test13->blocks->[2]->header,"parameters:","Usage header ok");
is($test13->blocks->[2]->body," extra1 Important extra parameter [Required]
extra2 [Integer]
alpha [Integer]","Usage body ok");
};
subtest 'Test missing positional params' => sub {
MooseX::App::ParsedArgv->new(argv => [qw(extra --value baer)]);
my $test14 = Test03->new_with_command;
isa_ok($test14,'MooseX::App::Message::Envelope');
is($test14->blocks->[0]->header,"Required parameter 'extra1' missing","Message ok");
};
Test03->meta->app_fuzzy(1);
Test03->meta->app_strict(0);
subtest 'Test extra positional params' => sub {
MooseX::App::ParsedArgv->new(argv => [qw(extra p1 22 33 marder dachs --value 44 --flag luchs --flagg fuchs -- baer --hase)]);
my $test15 = Test03->new_with_command;
isa_ok($test15,'Test03::ExtraCommand');
is($test15->extra1,'p1','Param 1 ok');
is($test15->extra2,'22','Param 2 ok');
is($test15->alpha,'33','Param 3 ok');
cmp_deeply($test15->extra_argv,[qw(marder dachs luchs fuchs baer --hase)],'Uncomsumed option ok');
};
subtest 'Test parameter preference' => sub {
MooseX::App::ParsedArgv->new(argv => [qw(extra extra1 22 --value 13 --flag)]);
my $test16 = Test03->new_with_command(extra1 => 'extra1man', value => 14, flag => 0, flaggo => 1);
isa_ok($test16,'Test03::ExtraCommand');
is($test16->extra1,"extra1man","Extra param from new_with_command ok");
is($test16->extra2,22,"Extra param from argv ok");
is($test16->value,14,"value option from argv ok");
is($test16->flag,0,"Flag from new_with_command ok");
is($test16->flaggo,1,"Flago from new_with_command ok");
};
Test03->meta->app_prefer_commandline(1);
subtest 'Test parameter preference reverse' => sub {
MooseX::App::ParsedArgv->new(argv => [qw(extra extra1 22 --value 13 --flag)]);
my $test17 = Test03->new_with_command(extra1 => 'extra1man', value => 14, flag => 0, flaggo => 1);
isa_ok($test17,'Test03::ExtraCommand');
is($test17->extra1,"extra1","Extra param from new_with_command ok");
is($test17->extra2,22,"Extra param from argv ok");
is($test17->value,13,"value option from argv ok");
is($test17->flag,1,"Flag from new_with_command ok");
is($test17->flaggo,1,"Flago from new_with_command ok");
};
subtest 'Test enum error message' => sub {
MooseX::App::ParsedArgv->new(argv => [qw(somecommand --another hase hh h ggg)]);
my $test18 = Test03->new_with_command();
isa_ok($test18,'MooseX::App::Message::Envelope');
like($test18->blocks->[0]->body,
qr{(Value must be one of these values: aaa, bbb, ccc, ddd, eee, fff \(not 'ggg'\)|Validation failed for '__ANON__' with value "?ggg"?. Value must be equal to "aaa", "bbb", "ccc", "ddd", "eee", or "fff".)},
"Check enum error message");
};
subtest 'Test empty multi' => sub {
MooseX::App::ParsedArgv->new(argv => [qw(somecommand --another hase --list val1 --list val2 --list)]);
my $test19 = Test03->new_with_command();
isa_ok($test19,'Test03::SomeCommand');
is(scalar(@{$test19->list}),3,'Has three list items');
is($test19->list->[0],'val1','First value ok');
is($test19->list->[1],'val2','Second value ok');
is($test19->list->[2],undef,'First value empty');
};
subtest 'Test permute' => sub {
MooseX::App::ParsedArgv->new(argv => [qw(differentcommand --list elem1 elem2 --list elem3 --int 10 --hash key1=val1 key2=val2)]);
my $test20 = Test03->new_with_command();
cmp_deeply($test20->list,[qw(elem1 elem2 elem3)],'Permute array ok');
cmp_deeply($test20->hash,{ key1 => 'val1', key2 => 'val2' },'Permute hash ok');
};
subtest 'Test permute off' => sub {
Test03->meta->app_permute(0);
MooseX::App::ParsedArgv->new(argv => [qw(differentcommand --list elem1 elem2 --list elem3 --int 10 --hash key1=val1 key2=val2)]);
my $test20 = Test03->new_with_command();
cmp_deeply($test20->list,[qw(elem1 elem3)],'No permute array ok');
cmp_deeply($test20->hash,{ key1 => 'val1' },'No permute hash ok');
Test03->meta->app_permute(1);
};
subtest 'Test parameter order' => sub {
MooseX::App::ParsedArgv->new(argv => [qw(somecommand cc1 --another dd aa1 bbb)]);
my $test21 = Test03->new_with_command();
is($test21->param_a,'aa1','Param a ok');
is($test21->param_b,'bbb','Param b ok');
is($test21->param_c,'cc1','Param c ok');
};
subtest 'Test mixed multi' => sub {
my $x = MooseX::App::ParsedArgv->new(argv => [qw(somecommand --another hase --li val1 --lis val2 --list val3 --lis val4)]);
my $test22 = Test03->new_with_command();
isa_ok($test22,'Test03::SomeCommand');
cmp_deeply($test22->list,[qw(val1 val2 val3 val4)],'List ok');
};
16_rt122946.t100644000765000024 127214514737355 14617 0ustar00mkostaff000000000000MooseX-App-1.43/t# -*- perl -*-
# t/16_rt122946.t
use strict;
use warnings;
use Test::More tests => 1+1;
use Test::NoWarnings;
use Test::Exception;
use lib 't/testlib';
{
package Test16;
use MooseX::App::Simple;
option 'parama' => (
is => 'rw',
isa => 'Int',
cmd_aliases => ['a']
);
option 'paramb' => (
is => 'rw',
isa => 'Bool',
cmd_aliases => ['b']
);
option 'paramab' => (
is => 'rw',
isa => 'Int',
cmd_aliases => ['ab']
);
}
subtest 'Option flags' => sub {
throws_ok {
Test16->new_with_options( ARGV => [ '-ab' ] )
} qr/Option param[ab] has a single letter flag but no Bool/;
};
perlcritic.t100644000765000024 101514514737355 15517 0ustar00mkostaff000000000000MooseX-App-1.43/xt# -*- perl -*-
use strict;
use warnings;
use File::Spec;
use Test::More;
use English qw(-no_match_vars);
if ( not $ENV{TEST_AUTHOR} ) {
my $msg = 'Author test. Set $ENV{TEST_AUTHOR} to a true value to run.';
plan( skip_all => $msg );
}
eval " use Test::Perl::Critic (-severity => 4, -exclude => ['ProhibitSubroutinePrototypes','ProhibitMultiplePackages'] ); ";
if ( $EVAL_ERROR ) {
my $msg = 'Test::Perl::Critic required to criticise code';
plan( skip_all => $msg );
}
Test::Perl::Critic::all_critic_ok();
13_rt_112156.t100644000765000024 457614514737355 14755 0ustar00mkostaff000000000000MooseX-App-1.43/t# -*- perl -*-
# t/13_rt_112156.t - RT112156 inheritance
use Test::Most tests => 2+1;
use Test::NoWarnings;
use lib 't/testlib';
{
package Test13;
use MooseX::App qw(Depends);
option 'unrelated' => (
is => 'rw',
isa => 'Int',
documentation => 'One thing',
);
}
{
package Test13::SomeCommand;
use MooseX::App::Command;
# no inheritance
option 'one' => (
is => 'rw',
isa => 'Int',
documentation => 'One thing',
depends => ['other'],
);
option 'other' => (
is => 'rw',
isa => 'Int',
documentation => 'Other thing',
);
sub run {
my ($self) = @_;
return "ok";
}
}
{
package Test13::AnotherCommand;
use MooseX::App::Command;
extends qw(Test13);
option 'one' => (
is => 'rw',
isa => 'Int',
documentation => 'One thing',
depends => ['other'],
);
option 'other' => (
is => 'rw',
isa => 'Int',
documentation => 'Other thing',
);
sub run {
my ($self) = @_;
return "ok";
}
}
subtest 'no inheritance' => sub {
plan tests => 8;
{
MooseX::App::ParsedArgv->new(argv => [qw(some --one 1 --other 2)]);
my $test01 = Test13->new_with_command();
isa_ok($test01,'Test13::SomeCommand');
is($test01->one,1,'Option ok');
is($test01->other,2,'Option ok');
ok(! $test01->can('unrelated'),'No option');
}
{
MooseX::App::ParsedArgv->new(argv => [qw(another --one 1 --other 2 --unrelated 3)]);
my $test02 = Test13->new_with_command();
isa_ok($test02,'Test13::AnotherCommand');
is($test02->one,1,'Option ok');
is($test02->other,2,'Option ok');
is($test02->unrelated,3,'Option ok');
}
};
subtest 'check plugin functionality' => sub {
plan tests => 2;
{
MooseX::App::ParsedArgv->new(argv => [qw(some --one 1)]);
my $test03 = Test13->new_with_command();
isa_ok( $test03, 'MooseX::App::Message::Envelope' );
}
{
MooseX::App::ParsedArgv->new(argv => [qw(another --one 1)]);
my $test03 = Test13->new_with_command();
isa_ok( $test03, 'MooseX::App::Message::Envelope' );
}
};
podcoverage.t100644000765000024 51414514737355 15640 0ustar00mkostaff000000000000MooseX-App-1.43/xt# -*- perl -*-
use strict;
use warnings;
use Test::More;
eval "use Test::Pod::Coverage 1.04";
plan skip_all => 'Test::Pod::Coverage 1.04 required' if $@;
plan skip_all => 'set TEST_AUTHOR to enable this test' unless $ENV{TEST_AUTHOR};
all_pod_coverage_ok({
also_private => [qw(init_meta plugin_metaroles BUILD DEMOLISH)]
});
MooseX000755000765000024 014514737355 14362 5ustar00mkostaff000000000000MooseX-App-1.43/libApp.pm100644000765000024 4761614514737355 15636 0ustar00mkostaff000000000000MooseX-App-1.43/lib/MooseX# ============================================================================«
package MooseX::App;
# ============================================================================«
use 5.010;
use utf8;
use strict;
use warnings;
our $AUTHORITY = 'cpan:MAROS';
our $VERSION = '1.43';
use MooseX::App::Meta::Role::Attribute::Option;
use MooseX::App::Exporter qw(app_usage app_description app_base app_fuzzy app_strict app_prefer_commandline app_permute option parameter);
use MooseX::App::Message::Envelope;
use Moose::Exporter;
use Scalar::Util qw(blessed);
my ($IMPORT,$UNIMPORT,$INIT_META) = Moose::Exporter->build_import_methods(
with_meta => [ qw(app_usage app_description app_namespace app_exclude app_base app_fuzzy app_command_name app_command_register app_strict app_prefer_commandline option parameter app_permute) ],
also => [ 'Moose' ],
as_is => [ 'new_with_command' ],
install => [ 'unimport','init_meta' ],
);
sub import {
my ( $class, @plugins ) = @_;
# Get caller
my ($caller_class) = caller();
# Process plugins
MooseX::App::Exporter->process_plugins($caller_class,@plugins);
# Call Moose-Exporter generated importer
return $class->$IMPORT( { into => $caller_class } );
}
sub init_meta {
my ($class,%args) = @_;
# Get required roles and metaroles
$args{roles} = ['MooseX::App::Role::Base'];
$args{metaroles} = {
class => [
'MooseX::App::Meta::Role::Class::Base',
'MooseX::App::Meta::Role::Class::Documentation'
],
attribute => [
'MooseX::App::Meta::Role::Attribute::Option'
],
};
return MooseX::App::Exporter->process_init_meta(%args);
}
sub app_command_name(&) {
my ( $meta, $namesub ) = @_;
return $meta->app_command_name($namesub);
}
sub app_command_register(%) {
my ( $meta, %commands ) = @_;
foreach my $command (keys %commands) {
$meta->command_register($command,$commands{$command});
}
return;
}
sub app_namespace(@) {
my ( $meta, @namespaces ) = @_;
return $meta->app_namespace( \@namespaces );
}
sub app_exclude(@) {
my ( $meta, @namespaces ) = @_;
return $meta->app_exclude( \@namespaces );
}
sub new_with_command {
my ($class,@args) = @_;
Moose->throw_error('new_with_command is a class method')
if ! defined $class || blessed($class);
my $meta = $class->meta;
my $metameta = $meta->meta;
# Sanity check
Moose->throw_error('new_with_command may only be called from the application base package:'.$class)
if $metameta->does_role('MooseX::App::Meta::Role::Class::Command')
|| ! $metameta->does_role('MooseX::App::Meta::Role::Class::Base');
$meta->command_check()
if $ENV{APP_DEVELOPER} || $ENV{HARNESS_ACTIVE};
# Extra args
my %args;
if (scalar @args == 1
&& ref($args[0]) eq 'HASH' ) {
%args = %{$args[0]};
} elsif (scalar @args % 2 == 0) {
%args = @args;
} else {
Moose->throw_error('new_with_command got invalid extra arguments');
}
# Get ARGV
my $argv = delete $args{ARGV};
my $parsed_argv;
if (defined $argv) {
$parsed_argv = MooseX::App::ParsedArgv->new( argv => $argv );
} else {
$parsed_argv = MooseX::App::ParsedArgv->instance();
}
my $first_argv = $parsed_argv->first_argv;
# Requested help
if (defined $first_argv
&& lc($first_argv) =~ m/^(help|h|\?|usage|-h|--help|-\?|--usage)$/) {
return MooseX::App::Message::Envelope->new(
$meta->command_usage_global(),
);
# No args
} elsif (! defined $first_argv
|| $first_argv =~ m/^\s*$/
|| $first_argv =~ m/^-{1,2}\w/) {
return MooseX::App::Message::Envelope->new(
$meta->command_message(
header => "Missing command", # LOCALIZE
type => "error",
),
$meta->command_usage_global(),
127, # exitcode
);
# Looks like a command
} else {
my $return = $meta->command_find();
# Nothing found
if (blessed $return
&& $return->isa('MooseX::App::Message::Block')) {
return MooseX::App::Message::Envelope->new(
$return,
$meta->command_usage_global(),
127, # exitcode
);
# One command found
} else {
my $command_class = $meta->command_get($return);
return $class->initialize_command_class($command_class,%args);
}
}
}
no Moose;
1;
__END__
=encoding utf8
=head1 NAME
MooseX::App - Write user-friendly command line apps with even less suffering
=head1 SYNOPSIS
In your base class:
package MyApp;
use MooseX::App qw(Color);
option 'global_option' => (
is => 'rw',
isa => 'Bool',
documentation => q[Enable this to do fancy stuff],
); # Global option
has 'private' => (
is => 'rw',
); # not exposed
Write multiple command classes (If you have only a single command class
you should use L instead). Packackes in the namespace may be
deeply nested.
package MyApp::SomeCommand;
use MooseX::App::Command; # important (also imports Moose)
extends qw(MyApp); # optional, only if you want to use global options from base class
# Positional parameter
parameter 'some_parameter' => (
is => 'rw',
isa => 'Str',
required => 1,
documentation => q[Some parameter that you need to supply],
);
option 'some_option' => (
is => 'rw',
isa => 'Int',
required => 1,
documentation => q[Very important option!],
); # Option
sub run {
my ($self) = @_;
# Do something
}
And then you need a simple wrapper script (called eg. myapp):
#!/usr/bin/env perl
use MyApp;
MyApp->new_with_command->run;
On the command line:
bash$ myapp help
usage:
myapp [long options...]
myapp help
global options:
--global_option Enable this to do fancy stuff [Flag]
--help --usage -? Prints this usage information. [Flag]
available commands:
some_command Description of some command
another_command Description of another command
help Prints this usage information
or
bash$ myapp some_command --help
usage:
myapp some_command [long options...]
myapp help
myapp some_command --help
parameters:
some_parameter Some parameter that you need to supply [Required]
options:
--global_option Enable this to do fancy stuff [Flag]
--some_option Very important option! [Int,Required]
--help --usage -? Prints this usage information. [Flag]
=head1 DESCRIPTION
MooseX-App is a highly customisable helper to write user-friendly
command line applications without having to worry about most of the annoying
things usually involved. Just take any existing L class, add a single
line (C