From 436886c5df64be7bd8117af044d0fe4d53542eaf Mon Sep 17 00:00:00 2001 From: Debian Perl Group Date: Mon, 4 Jan 2021 14:03:13 +0100 Subject: Fix test with Moose 2.201.400 Origin: Github issue Bug: https://github.com/maros/MooseX-App/issues/61 Forwarded: https://github.com/maros/MooseX-App/issues/61 Bug-Debian: https://bugs.debian.org/978302 Reviewed-by: gregor herrmann Last-Update: 2021-01-04 Gbp-Pq: Name fix-test-with-Moose-2.201.400.patch --- t/05_extended.t | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/t/05_extended.t b/t/05_extended.t index 37dab9a..4763518 100755 --- a/t/05_extended.t +++ b/t/05_extended.t @@ -241,7 +241,7 @@ subtest 'Test enum error message' => sub { MooseX::App::ParsedArgv->new(argv => [qw(somecommand --another hase hh h ggg)]); my $test18 = Test03->new_with_command(); isa_ok($test18,'MooseX::App::Message::Envelope'); - is($test18->blocks->[0]->body,"Value must be one of these values: aaa, bbb, ccc, ddd, eee, fff (not 'ggg')","Check enum error message"); + like($test18->blocks->[0]->body, qr/Value must be one of these values: aaa, bbb, ccc, ddd, eee, fff \(not 'ggg'\)|Value must be equal to "aaa", "bbb", "ccc", "ddd", "eee", or "fff"/, "Check enum error message"); }; subtest 'Test empty multi' => sub { -- cgit v1.2.3 From 58950f9a36a03e74366dba90a8453ba658ae37c0 Mon Sep 17 00:00:00 2001 From: gregor herrmann Date: Sun, 15 Aug 2021 21:26:52 +0200 Subject: Import libmoosex-app-perl_1.42.orig.tar.gz [dgit import orig libmoosex-app-perl_1.42.orig.tar.gz] --- Changes | 245 ++++ LICENCE | 383 +++++++ LICENSE | 379 +++++++ MANIFEST | 120 ++ META.json | 109 ++ META.yml | 52 + Makefile.PL | 61 + README.md | 484 ++++++++ TODO | 1 + cpanfile | 38 + dist.ini | 33 + lib/MooseX/App.pm | 697 ++++++++++++ lib/MooseX/App/Command.pm | 135 +++ lib/MooseX/App/Exporter.pm | 238 ++++ lib/MooseX/App/Message/Block.pm | 86 ++ lib/MooseX/App/Message/BlockColor.pm | 65 ++ lib/MooseX/App/Message/Envelope.pm | 183 +++ lib/MooseX/App/Meta/Role/Attribute/Option.pm | 517 +++++++++ lib/MooseX/App/Meta/Role/Class/Base.pm | 1170 ++++++++++++++++++++ lib/MooseX/App/Meta/Role/Class/Command.pm | 21 + lib/MooseX/App/Meta/Role/Class/Documentation.pm | 191 ++++ lib/MooseX/App/Meta/Role/Class/Simple.pm | 44 + lib/MooseX/App/ParsedArgv.pm | 380 +++++++ lib/MooseX/App/ParsedArgv/Element.pm | 163 +++ lib/MooseX/App/ParsedArgv/Value.pm | 54 + lib/MooseX/App/Plugin/BashCompletion.pm | 62 ++ lib/MooseX/App/Plugin/BashCompletion/Command.pm | 97 ++ lib/MooseX/App/Plugin/BashCompletion/Meta/Class.pm | 23 + lib/MooseX/App/Plugin/Color.pm | 38 + lib/MooseX/App/Plugin/Color/Meta/Class.pm | 17 + lib/MooseX/App/Plugin/Config.pm | 97 ++ lib/MooseX/App/Plugin/Config/Meta/Class.pm | 73 ++ lib/MooseX/App/Plugin/ConfigHome.pm | 47 + lib/MooseX/App/Plugin/ConfigHome/Meta/Class.pm | 37 + lib/MooseX/App/Plugin/Depends.pm | 71 ++ lib/MooseX/App/Plugin/Depends/Meta/Attribute.pm | 36 + lib/MooseX/App/Plugin/Depends/Meta/Class.pm | 41 + lib/MooseX/App/Plugin/Env.pm | 17 + lib/MooseX/App/Plugin/Fuzzy.pm | 18 + lib/MooseX/App/Plugin/Man.pm | 57 + lib/MooseX/App/Plugin/Man/Command.pm | 54 + lib/MooseX/App/Plugin/Man/Meta/Class.pm | 23 + lib/MooseX/App/Plugin/MutexGroup.pm | 73 ++ lib/MooseX/App/Plugin/MutexGroup/Meta/Attribute.pm | 35 + lib/MooseX/App/Plugin/MutexGroup/Meta/Class.pm | 57 + lib/MooseX/App/Plugin/Term.pm | 76 ++ lib/MooseX/App/Plugin/Term/Meta/Attribute.pm | 307 +++++ lib/MooseX/App/Plugin/Term/Meta/Class.pm | 49 + lib/MooseX/App/Plugin/Typo.pm | 48 + lib/MooseX/App/Plugin/Typo/Meta/Class.pm | 36 + lib/MooseX/App/Plugin/Version.pm | 69 ++ lib/MooseX/App/Plugin/Version/Command.pm | 44 + lib/MooseX/App/Plugin/Version/Meta/Class.pm | 23 + lib/MooseX/App/Role.pm | 68 ++ lib/MooseX/App/Role/Base.pm | 95 ++ lib/MooseX/App/Role/Common.pm | 27 + lib/MooseX/App/Simple.pm | 184 +++ lib/MooseX/App/Tutorial.pod | 252 +++++ lib/MooseX/App/Utils.pm | 324 ++++++ lib/MooseX/App/WritingPlugins.pod | 83 ++ meta/argv.pl | 16 + t/00_load.t | 88 ++ t/01_basic.t | 132 +++ t/02_meta.t | 75 ++ t/03_utils.t | 83 ++ t/04_plugin_config.t | 43 + t/05_extended.t | 288 +++++ t/06_env.t | 49 + t/07_single.t | 32 + t/08_plugin_various.t | 33 + t/09_classes.t | 66 ++ t/10_plugin_mutexgroup.t | 44 + t/11_process.t | 140 +++ t/12_plugin_depends.t | 51 + t/13_rt_112156.t | 105 ++ t/14_gh_45.t | 76 ++ t/15_subcommands.t | 67 ++ t/16_rt122946.t | 43 + t/config.pl | 9 + t/example/test01.pl | 11 + t/example/test02.pl | 11 + t/example/test03.pl | 11 + t/example/test04.pl | 11 + t/example/test05.pl | 11 + t/example/test06.pl | 11 + t/example/test07.pl | 11 + t/example/test08.pl | 11 + t/testlib/Test01.pm | 26 + t/testlib/Test01/CommandA.pm | 40 + t/testlib/Test01/CommandB.pm | 80 ++ t/testlib/Test01/CommandC1.pm | 16 + t/testlib/Test01/CommandD.pm | 38 + t/testlib/Test02.pm | 31 + t/testlib/Test02/Command/Error.pm | 21 + t/testlib/Test02/Command/Record.pm | 8 + t/testlib/Test02/Command/Required.pm | 21 + t/testlib/Test02/MoreCommands/Test.pm | 27 + t/testlib/Test03.pm | 37 + t/testlib/Test03/AnotherCommand.pm | 67 ++ t/testlib/Test03/BrokenCommand.pm | 22 + t/testlib/Test03/DifferentCommand.pm | 35 + t/testlib/Test03/ExtraCommand.pm | 49 + t/testlib/Test03/Role/TestRole.pm | 20 + t/testlib/Test03/SomeCommand.pm | 49 + t/testlib/Test03/YetAnotherCommand.pm | 43 + t/testlib/Test03CommandBase.pm | 15 + t/testlib/Test04.pm | 14 + t/testlib/Test04Base.pm | 24 + t/testlib/Test05.pm | 35 + t/testlib/Test06.pm | 22 + t/testlib/Test06/CommandA.pm | 30 + t/testlib/Test06/CommandB.pm | 17 + t/testlib/Test06/CommandD.pm | 26 + t/testlib/Test07.pm | 26 + t/testlib/Test08.pm | 30 + xt/perlcritic.t | 20 + xt/pod.t | 11 + xt/podcoverage.t | 13 + xt/podstyle.t | 46 + 119 files changed, 10994 insertions(+) create mode 100644 Changes create mode 100644 LICENCE create mode 100644 LICENSE create mode 100644 MANIFEST create mode 100644 META.json create mode 100644 META.yml create mode 100644 Makefile.PL create mode 100644 README.md create mode 100644 TODO create mode 100644 cpanfile create mode 100644 dist.ini create mode 100644 lib/MooseX/App.pm create mode 100644 lib/MooseX/App/Command.pm create mode 100644 lib/MooseX/App/Exporter.pm create mode 100644 lib/MooseX/App/Message/Block.pm create mode 100644 lib/MooseX/App/Message/BlockColor.pm create mode 100644 lib/MooseX/App/Message/Envelope.pm create mode 100644 lib/MooseX/App/Meta/Role/Attribute/Option.pm create mode 100644 lib/MooseX/App/Meta/Role/Class/Base.pm create mode 100644 lib/MooseX/App/Meta/Role/Class/Command.pm create mode 100644 lib/MooseX/App/Meta/Role/Class/Documentation.pm create mode 100644 lib/MooseX/App/Meta/Role/Class/Simple.pm create mode 100644 lib/MooseX/App/ParsedArgv.pm create mode 100644 lib/MooseX/App/ParsedArgv/Element.pm create mode 100644 lib/MooseX/App/ParsedArgv/Value.pm create mode 100644 lib/MooseX/App/Plugin/BashCompletion.pm create mode 100644 lib/MooseX/App/Plugin/BashCompletion/Command.pm create mode 100644 lib/MooseX/App/Plugin/BashCompletion/Meta/Class.pm create mode 100644 lib/MooseX/App/Plugin/Color.pm create mode 100644 lib/MooseX/App/Plugin/Color/Meta/Class.pm create mode 100644 lib/MooseX/App/Plugin/Config.pm create mode 100644 lib/MooseX/App/Plugin/Config/Meta/Class.pm create mode 100644 lib/MooseX/App/Plugin/ConfigHome.pm create mode 100644 lib/MooseX/App/Plugin/ConfigHome/Meta/Class.pm create mode 100644 lib/MooseX/App/Plugin/Depends.pm create mode 100644 lib/MooseX/App/Plugin/Depends/Meta/Attribute.pm create mode 100644 lib/MooseX/App/Plugin/Depends/Meta/Class.pm create mode 100644 lib/MooseX/App/Plugin/Env.pm create mode 100644 lib/MooseX/App/Plugin/Fuzzy.pm create mode 100644 lib/MooseX/App/Plugin/Man.pm create mode 100644 lib/MooseX/App/Plugin/Man/Command.pm create mode 100644 lib/MooseX/App/Plugin/Man/Meta/Class.pm create mode 100644 lib/MooseX/App/Plugin/MutexGroup.pm create mode 100644 lib/MooseX/App/Plugin/MutexGroup/Meta/Attribute.pm create mode 100644 lib/MooseX/App/Plugin/MutexGroup/Meta/Class.pm create mode 100644 lib/MooseX/App/Plugin/Term.pm create mode 100644 lib/MooseX/App/Plugin/Term/Meta/Attribute.pm create mode 100644 lib/MooseX/App/Plugin/Term/Meta/Class.pm create mode 100644 lib/MooseX/App/Plugin/Typo.pm create mode 100644 lib/MooseX/App/Plugin/Typo/Meta/Class.pm create mode 100644 lib/MooseX/App/Plugin/Version.pm create mode 100644 lib/MooseX/App/Plugin/Version/Command.pm create mode 100644 lib/MooseX/App/Plugin/Version/Meta/Class.pm create mode 100644 lib/MooseX/App/Role.pm create mode 100644 lib/MooseX/App/Role/Base.pm create mode 100644 lib/MooseX/App/Role/Common.pm create mode 100644 lib/MooseX/App/Simple.pm create mode 100644 lib/MooseX/App/Tutorial.pod create mode 100644 lib/MooseX/App/Utils.pm create mode 100644 lib/MooseX/App/WritingPlugins.pod create mode 100755 meta/argv.pl create mode 100755 t/00_load.t create mode 100755 t/01_basic.t create mode 100644 t/02_meta.t create mode 100755 t/03_utils.t create mode 100644 t/04_plugin_config.t create mode 100755 t/05_extended.t create mode 100644 t/06_env.t create mode 100644 t/07_single.t create mode 100644 t/08_plugin_various.t create mode 100644 t/09_classes.t create mode 100644 t/10_plugin_mutexgroup.t create mode 100644 t/11_process.t create mode 100644 t/12_plugin_depends.t create mode 100644 t/13_rt_112156.t create mode 100644 t/14_gh_45.t create mode 100644 t/15_subcommands.t create mode 100644 t/16_rt122946.t create mode 100644 t/config.pl create mode 100755 t/example/test01.pl create mode 100755 t/example/test02.pl create mode 100755 t/example/test03.pl create mode 100755 t/example/test04.pl create mode 100755 t/example/test05.pl create mode 100755 t/example/test06.pl create mode 100755 t/example/test07.pl create mode 100755 t/example/test08.pl create mode 100644 t/testlib/Test01.pm create mode 100644 t/testlib/Test01/CommandA.pm create mode 100644 t/testlib/Test01/CommandB.pm create mode 100644 t/testlib/Test01/CommandC1.pm create mode 100644 t/testlib/Test01/CommandD.pm create mode 100644 t/testlib/Test02.pm create mode 100644 t/testlib/Test02/Command/Error.pm create mode 100644 t/testlib/Test02/Command/Record.pm create mode 100644 t/testlib/Test02/Command/Required.pm create mode 100644 t/testlib/Test02/MoreCommands/Test.pm create mode 100644 t/testlib/Test03.pm create mode 100644 t/testlib/Test03/AnotherCommand.pm create mode 100644 t/testlib/Test03/BrokenCommand.pm create mode 100644 t/testlib/Test03/DifferentCommand.pm create mode 100644 t/testlib/Test03/ExtraCommand.pm create mode 100644 t/testlib/Test03/Role/TestRole.pm create mode 100644 t/testlib/Test03/SomeCommand.pm create mode 100644 t/testlib/Test03/YetAnotherCommand.pm create mode 100644 t/testlib/Test03CommandBase.pm create mode 100644 t/testlib/Test04.pm create mode 100644 t/testlib/Test04Base.pm create mode 100644 t/testlib/Test05.pm create mode 100644 t/testlib/Test06.pm create mode 100644 t/testlib/Test06/CommandA.pm create mode 100644 t/testlib/Test06/CommandB.pm create mode 100644 t/testlib/Test06/CommandD.pm create mode 100644 t/testlib/Test07.pm create mode 100644 t/testlib/Test08.pm create mode 100644 xt/perlcritic.t create mode 100644 xt/pod.t create mode 100644 xt/podcoverage.t create mode 100644 xt/podstyle.t diff --git a/Changes b/Changes new file mode 100644 index 0000000..05e37f9 --- /dev/null +++ b/Changes @@ -0,0 +1,245 @@ +Release history for Perl module MooseX::App + +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 diff --git a/LICENCE b/LICENCE new file mode 100644 index 0000000..9d0305b --- /dev/null +++ b/LICENCE @@ -0,0 +1,383 @@ +Terms of Perl itself + +a) the GNU General Public License as published by the Free + Software Foundation; either version 1, or (at your option) any + later version, or +b) the "Artistic License" + +--------------------------------------------------------------------------- + +The General Public License (GPL) +Version 2, June 1991 + +Copyright (C) 1989, 1991 Free Software Foundation, Inc. 675 Mass Ave, +Cambridge, MA 02139, USA. Everyone is permitted to copy and distribute +verbatim copies of this license document, but changing it is not allowed. + +Preamble + +The licenses for most software are designed to take away your freedom to share +and change it. By contrast, the GNU General Public License is intended to +guarantee your freedom to share and change free software--to make sure the +software is free for all its users. This General Public License applies to most of +the Free Software Foundation's software and to any other program whose +authors commit to using it. (Some other Free Software Foundation software is +covered by the GNU Library General Public License instead.) You can apply it to +your programs, too. + +When we speak of free software, we are referring to freedom, not price. Our +General Public Licenses are designed to make sure that you have the freedom +to distribute copies of free software (and charge for this service if you wish), that +you receive source code or can get it if you want it, that you can change the +software or use pieces of it in new free programs; and that you know you can do +these things. + +To protect your rights, we need to make restrictions that forbid anyone to deny +you these rights or to ask you to surrender the rights. These restrictions +translate to certain responsibilities for you if you distribute copies of the +software, or if you modify it. + +For example, if you distribute copies of such a program, whether gratis or for a +fee, you must give the recipients all the rights that you have. You must make +sure that they, too, receive or can get the source code. And you must show +them these terms so they know their rights. + +We protect your rights with two steps: (1) copyright the software, and (2) offer +you this license which gives you legal permission to copy, distribute and/or +modify the software. + +Also, for each author's protection and ours, we want to make certain that +everyone understands that there is no warranty for this free software. If the +software is modified by someone else and passed on, we want its recipients to +know that what they have is not the original, so that any problems introduced by +others will not reflect on the original authors' reputations. + +Finally, any free program is threatened constantly by software patents. We wish +to avoid the danger that redistributors of a free program will individually obtain +patent licenses, in effect making the program proprietary. To prevent this, we +have made it clear that any patent must be licensed for everyone's free use or +not licensed at all. + +The precise terms and conditions for copying, distribution and modification +follow. + +GNU GENERAL PUBLIC LICENSE +TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND +MODIFICATION + +0. This License applies to any program or other work which contains a notice +placed by the copyright holder saying it may be distributed under the terms of +this General Public License. The "Program", below, refers to any such program +or work, and a "work based on the Program" means either the Program or any +derivative work under copyright law: that is to say, a work containing the +Program or a portion of it, either verbatim or with modifications and/or translated +into another language. (Hereinafter, translation is included without limitation in +the term "modification".) Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not covered by +this License; they are outside its scope. The act of running the Program is not +restricted, and the output from the Program is covered only if its contents +constitute a work based on the Program (independent of having been made by +running the Program). Whether that is true depends on what the Program does. + +1. You may copy and distribute verbatim copies of the Program's source code as +you receive it, in any medium, provided that you conspicuously and appropriately +publish on each copy an appropriate copyright notice and disclaimer of warranty; +keep intact all the notices that refer to this License and to the absence of any +warranty; and give any other recipients of the Program a copy of this License +along with the Program. + +You may charge a fee for the physical act of transferring a copy, and you may at +your option offer warranty protection in exchange for a fee. + +2. You may modify your copy or copies of the Program or any portion of it, thus +forming a work based on the Program, and copy and distribute such +modifications or work under the terms of Section 1 above, provided that you also +meet all of these conditions: + +a) You must cause the modified files to carry prominent notices stating that you +changed the files and the date of any change. + +b) You must cause any work that you distribute or publish, that in whole or in +part contains or is derived from the Program or any part thereof, to be licensed +as a whole at no charge to all third parties under the terms of this License. + +c) If the modified program normally reads commands interactively when run, you +must cause it, when started running for such interactive use in the most ordinary +way, to print or display an announcement including an appropriate copyright +notice and a notice that there is no warranty (or else, saying that you provide a +warranty) and that users may redistribute the program under these conditions, +and telling the user how to view a copy of this License. (Exception: if the +Program itself is interactive but does not normally print such an announcement, +your work based on the Program is not required to print an announcement.) + +These requirements apply to the modified work as a whole. If identifiable +sections of that work are not derived from the Program, and can be reasonably +considered independent and separate works in themselves, then this License, +and its terms, do not apply to those sections when you distribute them as +separate works. But when you distribute the same sections as part of a whole +which is a work based on the Program, the distribution of the whole must be on +the terms of this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote it. + +Thus, it is not the intent of this section to claim rights or contest your rights to +work written entirely by you; rather, the intent is to exercise the right to control +the distribution of derivative or collective works based on the Program. + +In addition, mere aggregation of another work not based on the Program with the +Program (or with a work based on the Program) on a volume of a storage or +distribution medium does not bring the other work under the scope of this +License. + +3. You may copy and distribute the Program (or a work based on it, under +Section 2) in object code or executable form under the terms of Sections 1 and 2 +above provided that you also do one of the following: + +a) Accompany it with the complete corresponding machine-readable source +code, which must be distributed under the terms of Sections 1 and 2 above on a +medium customarily used for software interchange; or, + +b) Accompany it with a written offer, valid for at least three years, to give any +third party, for a charge no more than your cost of physically performing source +distribution, a complete machine-readable copy of the corresponding source +code, to be distributed under the terms of Sections 1 and 2 above on a medium +customarily used for software interchange; or, + +c) Accompany it with the information you received as to the offer to distribute +corresponding source code. (This alternative is allowed only for noncommercial +distribution and only if you received the program in object code or executable +form with such an offer, in accord with Subsection b above.) + +The source code for a work means the preferred form of the work for making +modifications to it. For an executable work, complete source code means all the +source code for all modules it contains, plus any associated interface definition +files, plus the scripts used to control compilation and installation of the +executable. However, as a special exception, the source code distributed need +not include anything that is normally distributed (in either source or binary form) +with the major components (compiler, kernel, and so on) of the operating system +on which the executable runs, unless that component itself accompanies the +executable. + +If distribution of executable or object code is made by offering access to copy +from a designated place, then offering equivalent access to copy the source +code from the same place counts as distribution of the source code, even though +third parties are not compelled to copy the source along with the object code. + +4. You may not copy, modify, sublicense, or distribute the Program except as +expressly provided under this License. Any attempt otherwise to copy, modify, +sublicense or distribute the Program is void, and will automatically terminate +your rights under this License. However, parties who have received copies, or +rights, from you under this License will not have their licenses terminated so long +as such parties remain in full compliance. + +5. You are not required to accept this License, since you have not signed it. +However, nothing else grants you permission to modify or distribute the Program +or its derivative works. These actions are prohibited by law if you do not accept +this License. Therefore, by modifying or distributing the Program (or any work +based on the Program), you indicate your acceptance of this License to do so, +and all its terms and conditions for copying, distributing or modifying the +Program or works based on it. + +6. Each time you redistribute the Program (or any work based on the Program), +the recipient automatically receives a license from the original licensor to copy, +distribute or modify the Program subject to these terms and conditions. You +may not impose any further restrictions on the recipients' exercise of the rights +granted herein. You are not responsible for enforcing compliance by third parties +to this License. + +7. If, as a consequence of a court judgment or allegation of patent infringement +or for any other reason (not limited to patent issues), conditions are imposed on +you (whether by court order, agreement or otherwise) that contradict the +conditions of this License, they do not excuse you from the conditions of this +License. If you cannot distribute so as to satisfy simultaneously your obligations +under this License and any other pertinent obligations, then as a consequence +you may not distribute the Program at all. For example, if a patent license would +not permit royalty-free redistribution of the Program by all those who receive +copies directly or indirectly through you, then the only way you could satisfy +both it and this License would be to refrain entirely from distribution of the +Program. + +If any portion of this section is held invalid or unenforceable under any particular +circumstance, the balance of the section is intended to apply and the section as +a whole is intended to apply in other circumstances. + +It is not the purpose of this section to induce you to infringe any patents or other +property right claims or to contest validity of any such claims; this section has +the sole purpose of protecting the integrity of the free software distribution +system, which is implemented by public license practices. Many people have +made generous contributions to the wide range of software distributed through +that system in reliance on consistent application of that system; it is up to the +author/donor to decide if he or she is willing to distribute software through any +other system and a licensee cannot impose that choice. + +This section is intended to make thoroughly clear what is believed to be a +consequence of the rest of this License. + +8. If the distribution and/or use of the Program is restricted in certain countries +either by patents or by copyrighted interfaces, the original copyright holder who +places the Program under this License may add an explicit geographical +distribution limitation excluding those countries, so that distribution is permitted +only in or among countries not thus excluded. In such case, this License +incorporates the limitation as if written in the body of this License. + +9. The Free Software Foundation may publish revised and/or new versions of the +General Public License from time to time. Such new versions will be similar in +spirit to the present version, but may differ in detail to address new problems or +concerns. + +Each version is given a distinguishing version number. If the Program specifies a +version number of this License which applies to it and "any later version", you +have the option of following the terms and conditions either of that version or of +any later version published by the Free Software Foundation. If the Program does +not specify a version number of this License, you may choose any version ever +published by the Free Software Foundation. + +10. If you wish to incorporate parts of the Program into other free programs +whose distribution conditions are different, write to the author to ask for +permission. For software which is copyrighted by the Free Software Foundation, +write to the Free Software Foundation; we sometimes make exceptions for this. +Our decision will be guided by the two goals of preserving the free status of all +derivatives of our free software and of promoting the sharing and reuse of +software generally. + +NO WARRANTY + +11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS +NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY +APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE +COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM +"AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR +IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE +ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE +PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, +YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR +CORRECTION. + +12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED +TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY +WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS +PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY +GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES +ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM +(INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING +RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD +PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY +OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS +BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. + +END OF TERMS AND CONDITIONS + + +--------------------------------------------------------------------------- + +The Artistic License + +Preamble + +The intent of this document is to state the conditions under which a Package +may be copied, such that the Copyright Holder maintains some semblance of +artistic control over the development of the package, while giving the users of the +package the right to use and distribute the Package in a more-or-less customary +fashion, plus the right to make reasonable modifications. + +Definitions: + +- "Package" refers to the collection of files distributed by the Copyright + Holder, and derivatives of that collection of files created through textual + modification. +- "Standard Version" refers to such a Package if it has not been modified, + or has been modified in accordance with the wishes of the Copyright + Holder. +- "Copyright Holder" is whoever is named in the copyright or copyrights for + the package. +- "You" is you, if you're thinking about copying or distributing this Package. +- "Reasonable copying fee" is whatever you can justify on the basis of + media cost, duplication charges, time of people involved, and so on. (You + will not be required to justify it to the Copyright Holder, but only to the + computing community at large as a market that must bear the fee.) +- "Freely Available" means that no fee is charged for the item itself, though + there may be fees involved in handling the item. It also means that + recipients of the item may redistribute it under the same conditions they + received it. + +1. You may make and give away verbatim copies of the source form of the +Standard Version of this Package without restriction, provided that you duplicate +all of the original copyright notices and associated disclaimers. + +2. You may apply bug fixes, portability fixes and other modifications derived from +the Public Domain or from the Copyright Holder. A Package modified in such a +way shall still be considered the Standard Version. + +3. You may otherwise modify your copy of this Package in any way, provided +that you insert a prominent notice in each changed file stating how and when +you changed that file, and provided that you do at least ONE of the following: + + a) place your modifications in the Public Domain or otherwise + make them Freely Available, such as by posting said modifications + to Usenet or an equivalent medium, or placing the modifications on + a major archive site such as ftp.uu.net, or by allowing the + Copyright Holder to include your modifications in the Standard + Version of the Package. + + b) use the modified Package only within your corporation or + organization. + + c) rename any non-standard executables so the names do not + conflict with standard executables, which must also be provided, + and provide a separate manual page for each non-standard + executable that clearly documents how it differs from the Standard + Version. + + d) make other distribution arrangements with the Copyright Holder. + +4. You may distribute the programs of this Package in object code or executable +form, provided that you do at least ONE of the following: + + a) distribute a Standard Version of the executables and library + files, together with instructions (in the manual page or equivalent) + on where to get the Standard Version. + + b) accompany the distribution with the machine-readable source of + the Package with your modifications. + + c) accompany any non-standard executables with their + corresponding Standard Version executables, giving the + non-standard executables non-standard names, and clearly + documenting the differences in manual pages (or equivalent), + together with instructions on where to get the Standard Version. + + d) make other distribution arrangements with the Copyright Holder. + +5. You may charge a reasonable copying fee for any distribution of this Package. +You may charge any fee you choose for support of this Package. You may not +charge a fee for this Package itself. However, you may distribute this Package in +aggregate with other (possibly commercial) programs as part of a larger +(possibly commercial) software distribution provided that you do not advertise +this Package as a product of your own. + +6. The scripts and library files supplied as input to or produced as output from +the programs of this Package do not automatically fall under the copyright of this +Package, but belong to whomever generated them, and may be sold +commercially, and may be aggregated with this Package. + +7. C or perl subroutines supplied by you and linked into this Package shall not +be considered part of this Package. + +8. Aggregation of this Package with a commercial distribution is always permitted +provided that the use of this Package is embedded; that is, when no overt attempt +is made to make this Package's interfaces visible to the end user of the +commercial distribution. Such use shall not be construed as a distribution of +this Package. + +9. The name of the Copyright Holder may not be used to endorse or promote +products derived from this software without specific prior written permission. + +10. THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR +IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED +WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR +PURPOSE. + +The End + + diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..5047b0b --- /dev/null +++ b/LICENSE @@ -0,0 +1,379 @@ +This software is copyright (c) 2012 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) 2012 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 Artistic License 1.0 --- + +This software is Copyright (c) 2012 by Maroš Kollár. + +This is free software, licensed under: + + The Artistic License 1.0 + +The Artistic License + +Preamble + +The intent of this document is to state the conditions under which a Package +may be copied, such that the Copyright Holder maintains some semblance of +artistic control over the development of the package, while giving the users of +the package the right to use and distribute the Package in a more-or-less +customary fashion, plus the right to make reasonable modifications. + +Definitions: + + - "Package" refers to the collection of files distributed by the Copyright + Holder, and derivatives of that collection of files created through + textual modification. + - "Standard Version" refers to such a Package if it has not been modified, + or has been modified in accordance with the wishes of the Copyright + Holder. + - "Copyright Holder" is whoever is named in the copyright or copyrights for + the package. + - "You" is you, if you're thinking about copying or distributing this Package. + - "Reasonable copying fee" is whatever you can justify on the basis of media + cost, duplication charges, time of people involved, and so on. (You will + not be required to justify it to the Copyright Holder, but only to the + computing community at large as a market that must bear the fee.) + - "Freely Available" means that no fee is charged for the item itself, though + there may be fees involved in handling the item. It also means that + recipients of the item may redistribute it under the same conditions they + received it. + +1. You may make and give away verbatim copies of the source form of the +Standard Version of this Package without restriction, provided that you +duplicate all of the original copyright notices and associated disclaimers. + +2. You may apply bug fixes, portability fixes and other modifications derived +from the Public Domain or from the Copyright Holder. A Package modified in such +a way shall still be considered the Standard Version. + +3. You may otherwise modify your copy of this Package in any way, provided that +you insert a prominent notice in each changed file stating how and when you +changed that file, and provided that you do at least ONE of the following: + + a) place your modifications in the Public Domain or otherwise make them + Freely Available, such as by posting said modifications to Usenet or an + equivalent medium, or placing the modifications on a major archive site + such as ftp.uu.net, or by allowing the Copyright Holder to include your + modifications in the Standard Version of the Package. + + b) use the modified Package only within your corporation or organization. + + c) rename any non-standard executables so the names do not conflict with + standard executables, which must also be provided, and provide a separate + manual page for each non-standard executable that clearly documents how it + differs from the Standard Version. + + d) make other distribution arrangements with the Copyright Holder. + +4. You may distribute the programs of this Package in object code or executable +form, provided that you do at least ONE of the following: + + a) distribute a Standard Version of the executables and library files, + together with instructions (in the manual page or equivalent) on where to + get the Standard Version. + + b) accompany the distribution with the machine-readable source of the Package + with your modifications. + + c) accompany any non-standard executables with their corresponding Standard + Version executables, giving the non-standard executables non-standard + names, and clearly documenting the differences in manual pages (or + equivalent), together with instructions on where to get the Standard + Version. + + d) make other distribution arrangements with the Copyright Holder. + +5. You may charge a reasonable copying fee for any distribution of this +Package. You may charge any fee you choose for support of this Package. You +may not charge a fee for this Package itself. However, you may distribute this +Package in aggregate with other (possibly commercial) programs as part of a +larger (possibly commercial) software distribution provided that you do not +advertise this Package as a product of your own. + +6. The scripts and library files supplied as input to or produced as output +from the programs of this Package do not automatically fall under the copyright +of this Package, but belong to whomever generated them, and may be sold +commercially, and may be aggregated with this Package. + +7. C or perl subroutines supplied by you and linked into this Package shall not +be considered part of this Package. + +8. The name of the Copyright Holder may not be used to endorse or promote +products derived from this software without specific prior written permission. + +9. THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED +WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF +MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. + +The End + diff --git a/MANIFEST b/MANIFEST new file mode 100644 index 0000000..f8a1f4d --- /dev/null +++ b/MANIFEST @@ -0,0 +1,120 @@ +# This file was automatically generated by Dist::Zilla::Plugin::Manifest v6.012. +Changes +LICENCE +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/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 diff --git a/META.json b/META.json new file mode 100644 index 0000000..99532bc --- /dev/null +++ b/META.json @@ -0,0 +1,109 @@ +{ + "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.012, CPAN::Meta::Converter version 2.150005", + "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" : { + "Config::Any" : "0", + "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" : { + "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.42", + "x_generated_by_perl" : "v5.24.0", + "x_serialization_backend" : "Cpanel::JSON::XS version 3.0217" +} + diff --git a/META.yml b/META.yml new file mode 100644 index 0000000..2d30067 --- /dev/null +++ b/META.yml @@ -0,0 +1,52 @@ +--- +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.012, CPAN::Meta::Converter version 2.150005' +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: + Config::Any: '0' + File::HomeDir: '0' + term: + description: 'Term plugin' + requires: + IO::Interactive: '0' + Term::ANSIColor: '0' + typo: + description: 'Typo plugin' + requires: + Text::WagnerFischer: '0' +requires: + 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.42' +x_generated_by_perl: v5.24.0 +x_serialization_backend: 'YAML::Tiny version 1.69' diff --git a/Makefile.PL b/Makefile.PL new file mode 100644 index 0000000..b5e80de --- /dev/null +++ b/Makefile.PL @@ -0,0 +1,61 @@ +# This file was automatically generated by Dist::Zilla::Plugin::MakeMaker v6.012. +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" => { + "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.42", + "test" => { + "TESTS" => "t/*.t" + } +); + + +my %FallbackPrereqs = ( + "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); diff --git a/README.md b/README.md new file mode 100644 index 0000000..da5dcfd --- /dev/null +++ b/README.md @@ -0,0 +1,484 @@ +# 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::App::Simple) instead). Packackes in the namespace may be +deeply nested. + + package MyApp::SomeCommand; + use MooseX::App::Command; # important (also imports Moose) + extends qw(MyApp); # optional, only if you want to use global options from base class + + # Positional parameter + parameter 'some_parameter' => ( + is => 'rw', + isa => 'Str', + required => 1, + documentation => q[Some parameter that you need to supply], + ); + + option 'some_option' => ( + is => 'rw', + isa => 'Int', + required => 1, + documentation => q[Very important option!], + ); # Option + + sub run { + my ($self) = @_; + # Do something + } + +And then you need a simple wrapper script (called eg. myapp): + + #!/usr/bin/env perl + use MyApp; + MyApp->new_with_command->run; + +On the command line: + + bash$ myapp help + usage: + myapp [long options...] + myapp help + + global options: + --global_option Enable this to do fancy stuff [Flag] + --help --usage -? Prints this usage information. [Flag] + + available commands: + some_command Description of some command + another_command Description of another command + help Prints this usage information + +or + + bash$ myapp some_command --help + usage: + myapp some_command [long options...] + myapp help + myapp some_command --help + + parameters: + some_parameter Some parameter that you need to supply [Required] + + options: + --global_option Enable this to do fancy stuff [Flag] + --some_option Very important option! [Int,Required] + --help --usage -? Prints this usage information. [Flag] + +# DESCRIPTION + +MooseX-App is a highly customisable helper to write user-friendly +command line applications without having to worry about most of the annoying +things usually involved. Just take any existing [Moose](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::App::Simple) for single class/command applications) +- Create automated help and documentation from modules POD as well as +attributes metadata and type constraints +- Read, encode and validate the command line options and positional +parameters entered by the user from @ARGV and %ENV (and possibly prompt +the user for additional parameters see [MooseX::App::Plugin::Term](https://metacpan.org/pod/MooseX::App::Plugin::Term)) +- Provide helpful error messages if user input cannot be validated +(either missing or wrong attributes or Moose type constraints not satisfied) +or if the user requests help. + +Commandline options are defined using the 'option' keyword which accepts +the same attributes as Moose' 'has' keyword. + + option 'some_option' => ( + is => 'rw', + isa => 'Str', + ); + +This is equivalent to + + has 'some_option' => ( + is => 'rw', + isa => 'Str', + traits => ['AppOption'], # Load extra metaclass + cmd_type => 'option', # Set attribute type + ); + +Single letter options are treated as flags and may be combined with eachother. +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::App) (in the app base class) and +[MooseX::App::Command](https://metacpan.org/pod/MooseX::App::Command) (in the command class) or [MooseX::App::Simple](https://metacpan.org/pod/MooseX::App::Simple) +(single class application). + +Furthermore, all options and parameters can also be supplied via %ENV + + option 'some_option' => ( + is => 'rw', + isa => 'Str', + cmd_env => 'SOME_OPTION', # sets the env key + ); + +Moose type constraints help MooseX::App to construct helpful error messages +and parse @ARGV in a meaningful way. The following type constraints are +supported: + +- ArrayRef: Specify multiple values ('--opt value1 --opt value2', +also see [app\_permute](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::App::Tutorial) for getting started with a simple +MooseX::App command line application. + +# METHODS + +## new\_with\_command + + my $myapp_command = MyApp->new_with_command(); + +This constructor reads the command line arguments and tries to create a +command class instance. If it fails it returns a +[MooseX::App::Message::Envelope](https://metacpan.org/pod/MooseX::App::Message::Envelope) object holding an error message. + +You can pass a hash of default/fallback params to new\_with\_command + + my $obj = MyApp->new_with_command(%default); + +Optionally you can pass a custom ARGV to this constructor + + my $obj = MyApp->new_with_command( ARGV => \@myARGV ); + +However, if you do so you must take care of propper @ARGV encoding yourself. + +## initialize\_command\_class + + my $obj = MyApp->initialize_command_class($command_name,%default); + +Helper method to instantiate the command class for the given command. + +# GLOBAL OPTIONS + +These options may be used to alter the default behaviour of MooseX-App. + +## app\_base + + app_base 'my_script'; # Defaults to $0 + +Usually MooseX::App will take the name of the calling wrapper script to +construct the program name in various help messages. This name can +be changed via the app\_base function. + +## app\_fuzzy + + app_fuzzy 1; # default + OR + app_fuzzy 0; + +Enables fuzzy matching of commands and attributes. Is turned on by default. + +## app\_strict + + app_strict 0; # default + OR + app_strict 1; + +If strict is enabled the program will terminate with an error message if +superfluous/unknown positional parameters are supplied. If disabled all +extra parameters will be copied to the [extra\_argv](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 (or the default behaviour) can +be excluded using app\_exclude. + +## app\_command\_name + + app_command_name { + my ($package_short,$package_full) = @_; + # munge package name; + return $command_name; + }; + +This coderef can be used to control how autoloaded package names should be +translated to command names. If this command returns nothing the respective +command class will be skipped and not loaded. + +## app\_command\_register + + app_command_register + do => 'MyApp::Commands::DoSomething', + undo => 'MyApp::Commands::UndoSomething'; + +This keyword can be used to register additional commands. Especially +useful in conjunction with app\_namespace and disabled autoloading. + +## app\_description + + app_description qq[Description text]; + +Set the app description text. If not set this information will be taken from +the Pod DESCRIPTION or OVERVIEW sections. (see command\_description to set +usage per command) + +## app\_usage + + app_usage qq[myapp --option ...]; + +Set a custom usage text. If not set this will be taken from the Pod SYNOPSIS +or USAGE section. If both sections are not available, the usage information +will be autogenerated. (see command\_usage to set usage per command) + +## app\_permute + + app_permute 0; # default + OR + app_permute 1; + +Allows one to specify multiple values with one key. So instead of writing +`--list element1 --list element2 --list element3` one might write +`--list element1 element2 element3` for ArrayRef elements. HashRef elements +may be expressed as <--hash key=value key2=value2>. + +# GLOBAL ATTRIBUTES + +All MooseX::App classes will have two extra attributes + +## extra\_argv + +Carries all parameters from @ARGV that were not consumed (only if app\_strict +is turned off, otherwise superfluous parameters will raise an exception). + +## help\_flag + +Help flag that is set when help was requested. + +# ATTRIBUTE OPTIONS + +Options and parameters accept extra attributes for customisation: + +- cmd\_tags - Extra tags (as used by the help) +- cmd\_flag - Override option/parameter name +- cmd\_aliases - Additional option/parameter name aliases +- cmd\_split - Split values into ArrayRefs on this token +- cmd\_position - Specify option/parameter order in help +- cmd\_env - Read options/parameters from %ENV +- cmd\_count - Value of option equals to number of occurrences in @ARGV +- cmd\_negate - Adds an option to negate boolean flags + +Refer to [MooseX::App::Meta::Role::Attribute::Option](https://metacpan.org/pod/MooseX::App::Meta::Role::Attribute::Option) for detailed +documentation. + +# METADATA + +MooseX::App will use your class metadata and POD to construct the commands and +helpful error- or usage-messages. These bits of information are utilised +and should be provided if possible: + +- Package names +- [required](https://metacpan.org/pod/required) options for Moose attributes +- [documentation](https://metacpan.org/pod/documentation) options for Moose attributes +- Moose type constraints (Bool, ArrayRef, HashRef, Int, Num, and Enum) +- Documentation set via app\_description, app\_usage, +command\_short\_description, command\_long\_description and command\_usage +- POD (NAME, ABSTRACT, DESCRIPTION, USAGE, SYNOPSIS, OVERVIEW, +COPYRIGHT, LICENSE, COPYRIGHT AND LICENSE, AUTHOR and AUTHORS sections) +- Dzil ABSTRACT tag if no POD is available yet + +# PLUGINS + +The behaviour of MooseX-App can be customised with plugins. To load a +plugin just pass a list of plugin names after the `use MooseX-App` statement. +(Attention: order sometimes matters) + + use MooseX::App qw(PluginA PluginB); + +Currently the following plugins are shipped with MooseX::App + +- [MooseX::App::Plugin::BashCompletion](https://metacpan.org/pod/MooseX::App::Plugin::BashCompletion) + + Adds a command that generates a bash completion script for your application. + See third party [MooseX::App::Plugin::ZshCompletion](https://metacpan.org/pod/MooseX::App::Plugin::ZshCompletion) for Z shell completion. + +- [MooseX::App::Plugin::Color](https://metacpan.org/pod/MooseX::App::Plugin::Color) + + Colorful output for your MooseX::App applications. + +- [MooseX::App::Plugin::Config](https://metacpan.org/pod/MooseX::App::Plugin::Config) + + Config files for MooseX::App applications. + +- [MooseX::App::Plugin::ConfigHome](https://metacpan.org/pod/MooseX::App::Plugin::ConfigHome) + + Try to find config files in users home directory. + +- [MooseX::App::Plugin::Term](https://metacpan.org/pod/MooseX::App::Plugin::Term) + + Prompt user for options and parameters that were not provided via options or + params. Prompt offers basic editing capabilities and non-persistent history. + +- [MooseX::App::Plugin::Typo](https://metacpan.org/pod/MooseX::App::Plugin::Typo) + + Handle typos in command names and provide suggestions. + +- [MooseX::App::Plugin::Version](https://metacpan.org/pod/MooseX::App::Plugin::Version) + + Adds a command to display the version and license of your application. + +- [MooseX::App::Plugin::Man](https://metacpan.org/pod/MooseX::App::Plugin::Man) + + Display full manpage of application and commands. + +- [MooseX::App::Plugin::MutexGroup](https://metacpan.org/pod/MooseX::App::Plugin::MutexGroup) + + Allow for mutally exclusive options. + +- [MooseX::App::Plugin::Depends](https://metacpan.org/pod/MooseX::App::Plugin::Depends) + + Adds dependent options. + +Refer to [Writing MooseX-App Plugins](https://metacpan.org/pod/MooseX::App::WritingPlugins) +for documentation on how to create your own plugins. + +# CAVEATS & KNOWN BUGS + +Startup time may be an issue - escpecially if you load many plugins. If you do +not require the functionality of plugins and ability for fine grained +customisation (or Moose for that matter) then you should probably +use [MooX::Options](https://metacpan.org/pod/MooX::Options) or [MooX::Cmd](https://metacpan.org/pod/MooX::Cmd). + +In some cases - especially when using non-standard class inheritance - you may +end up with command classes lacking the help attribute. In this case you need +to include the following line in your base class or command classes. + + with qw(MooseX::App::Role::Common); + +When manually registering command classes (eg. via app\_command\_register) in +multiple base classes with different sets of plugins (why would you ever want +to do that?), then meta attributes may lack some attribute metaclasses. In +this case you need to load the missing attribute traits explicitly: + + option 'argument' => ( + depends => 'otherargument', + trait => ['MooseX::App::Plugin::Depends::Meta::Attribute'], # load trait + ); + +# SEE ALSO + +Read the [Tutorial](https://metacpan.org/pod/MooseX::App::Tutorial) 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::App::Cmd), [MooseX::Getopt](https://metacpan.org/pod/MooseX::Getopt), [MooX::Options](https://metacpan.org/pod/MooX::Options), [MooX::Cmd](https://metacpan.org/pod/MooX::Cmd)and [App::Cmd](https://metacpan.org/pod/App::Cmd) + +# 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 + +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-17 Maroš Kollár. + +This library is free software and may be distributed under the same terms as +perl itself. The full text of the licence can be found in the LICENCE file +included with this module. diff --git a/TODO b/TODO new file mode 100644 index 0000000..192a34f --- /dev/null +++ b/TODO @@ -0,0 +1 @@ +https://github.com/maros/MooseX-App/issues?q=is%3Aissue+is%3Aopen+label%3AWhishlist \ No newline at end of file diff --git a/cpanfile b/cpanfile new file mode 100644 index 0000000..a7c9879 --- /dev/null +++ b/cpanfile @@ -0,0 +1,38 @@ +requires 'Moose', '2.00'; +requires 'namespace::autoclean'; +requires 'Module::Pluggable'; +requires 'File::Basename'; +requires 'File::Spec'; +requires 'List::Util', '1.44'; +requires 'Pod::Elemental'; + +feature 'config', 'Config plugins' => sub { + requires 'Config::Any'; # or recommends + 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'; +}; diff --git a/dist.ini b/dist.ini new file mode 100644 index 0000000..e1c08f0 --- /dev/null +++ b/dist.ini @@ -0,0 +1,33 @@ +name = MooseX-App +author = Maroš Kollár +license = Perl_5 +copyright_holder = Maroš Kollár +copyright_year = 2012 +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] diff --git a/lib/MooseX/App.pm b/lib/MooseX/App.pm new file mode 100644 index 0000000..46761ce --- /dev/null +++ b/lib/MooseX/App.pm @@ -0,0 +1,697 @@ +# ============================================================================« +package MooseX::App; +# ============================================================================« + +use 5.010; +use utf8; +use strict; +use warnings; + +our $AUTHORITY = 'cpan:MAROS'; +our $VERSION = '1.42'; + +use MooseX::App::Meta::Role::Attribute::Option; +use MooseX::App::Exporter qw(app_usage app_description app_base app_fuzzy app_strict app_prefer_commandline app_permute option parameter); +use MooseX::App::Message::Envelope; +use Moose::Exporter; +use Scalar::Util qw(blessed); + +my ($IMPORT,$UNIMPORT,$INIT_META) = Moose::Exporter->build_import_methods( + with_meta => [ qw(app_usage app_description app_namespace app_exclude app_base app_fuzzy app_command_name app_command_register app_strict app_prefer_commandline option parameter app_permute) ], + also => [ 'Moose' ], + as_is => [ 'new_with_command' ], + install => [ 'unimport','init_meta' ], +); + +sub import { + my ( $class, @plugins ) = @_; + + # Get caller + my ($caller_class) = caller(); + + # Process plugins + MooseX::App::Exporter->process_plugins($caller_class,@plugins); + + # Call Moose-Exporter generated importer + return $class->$IMPORT( { into => $caller_class } ); +} + +sub init_meta { + my ($class,%args) = @_; + + # Get required roles and metaroles + $args{roles} = ['MooseX::App::Role::Base']; + $args{metaroles} = { + class => [ + 'MooseX::App::Meta::Role::Class::Base', + 'MooseX::App::Meta::Role::Class::Documentation' + ], + attribute => [ + 'MooseX::App::Meta::Role::Attribute::Option' + ], + }; + + return MooseX::App::Exporter->process_init_meta(%args); +} + +sub app_command_name(&) { + my ( $meta, $namesub ) = @_; + return $meta->app_command_name($namesub); +} + +sub app_command_register(%) { + my ( $meta, %commands ) = @_; + + foreach my $command (keys %commands) { + $meta->command_register($command,$commands{$command}); + } + return; +} + +sub app_namespace(@) { + my ( $meta, @namespaces ) = @_; + return $meta->app_namespace( \@namespaces ); +} + +sub app_exclude(@) { + my ( $meta, @namespaces ) = @_; + return $meta->app_exclude( \@namespaces ); +} + +sub new_with_command { + my ($class,@args) = @_; + + Moose->throw_error('new_with_command is a class method') + if ! defined $class || blessed($class); + + my $meta = $class->meta; + my $metameta = $meta->meta; + + # Sanity check + Moose->throw_error('new_with_command may only be called from the application base package:'.$class) + if $metameta->does_role('MooseX::App::Meta::Role::Class::Command') + || ! $metameta->does_role('MooseX::App::Meta::Role::Class::Base'); + + $meta->command_check() + if $ENV{APP_DEVELOPER} || $ENV{HARNESS_ACTIVE}; + + # Extra args + my %args; + if (scalar @args == 1 + && ref($args[0]) eq 'HASH' ) { + %args = %{$args[0]}; + } elsif (scalar @args % 2 == 0) { + %args = @args; + } else { + Moose->throw_error('new_with_command got invalid extra arguments'); + } + + # Get ARGV + my $argv = delete $args{ARGV}; + my $parsed_argv; + if (defined $argv) { + $parsed_argv = MooseX::App::ParsedArgv->new( argv => $argv ); + } else { + $parsed_argv = MooseX::App::ParsedArgv->instance(); + } + + my $first_argv = $parsed_argv->first_argv; + + # Requested help + if (defined $first_argv + && lc($first_argv) =~ m/^(help|h|\?|usage|-h|--help|-\?|--usage)$/) { + return MooseX::App::Message::Envelope->new( + $meta->command_usage_global(), + ); + # No args + } elsif (! defined $first_argv + || $first_argv =~ m/^\s*$/ + || $first_argv =~ m/^-{1,2}\w/) { + return MooseX::App::Message::Envelope->new( + $meta->command_message( + header => "Missing command", # LOCALIZE + type => "error", + ), + $meta->command_usage_global(), + 127, # exitcode + ); + # Looks like a command + } else { + my $return = $meta->command_find(); + + # Nothing found + if (blessed $return + && $return->isa('MooseX::App::Message::Block')) { + return MooseX::App::Message::Envelope->new( + $return, + $meta->command_usage_global(), + 127, # exitcode + ); + # One command found + } else { + my $command_class = $meta->command_get($return); + return $class->initialize_command_class($command_class,%args); + } + } +} + + +no Moose; +1; + +__END__ + +=encoding utf8 + +=head1 NAME + +MooseX::App - Write user-friendly command line apps with even less suffering + +=head1 SYNOPSIS + +In your base class: + + package MyApp; + use MooseX::App qw(Color); + + option 'global_option' => ( + is => 'rw', + isa => 'Bool', + documentation => q[Enable this to do fancy stuff], + ); # Global option + + has 'private' => ( + is => 'rw', + ); # not exposed + +Write multiple command classes (If you have only a single command class +you should use L instead). Packackes in the namespace may be +deeply nested. + + package MyApp::SomeCommand; + use MooseX::App::Command; # important (also imports Moose) + extends qw(MyApp); # optional, only if you want to use global options from base class + + # Positional parameter + parameter 'some_parameter' => ( + is => 'rw', + isa => 'Str', + required => 1, + documentation => q[Some parameter that you need to supply], + ); + + option 'some_option' => ( + is => 'rw', + isa => 'Int', + required => 1, + documentation => q[Very important option!], + ); # Option + + sub run { + my ($self) = @_; + # Do something + } + +And then you need a simple wrapper script (called eg. myapp): + + #!/usr/bin/env perl + use MyApp; + MyApp->new_with_command->run; + +On the command line: + + bash$ myapp help + usage: + myapp [long options...] + myapp help + + global options: + --global_option Enable this to do fancy stuff [Flag] + --help --usage -? Prints this usage information. [Flag] + + available commands: + some_command Description of some command + another_command Description of another command + help Prints this usage information + +or + + bash$ myapp some_command --help + usage: + myapp some_command [long options...] + myapp help + myapp some_command --help + + parameters: + some_parameter Some parameter that you need to supply [Required] + + options: + --global_option Enable this to do fancy stuff [Flag] + --some_option Very important option! [Int,Required] + --help --usage -? Prints this usage information. [Flag] + +=head1 DESCRIPTION + +MooseX-App is a highly customisable helper to write user-friendly +command line applications without having to worry about most of the annoying +things usually involved. Just take any existing L class, add a single +line (C) and create one class +for each command in an underlying namespace. Options and positional parameters +can be defined as simple L accessors using the C