t000755001751001751 012741266240 12746 5ustar00devdev000000000000MooX-Options-4.023mo.t100644001751001751 1224012741266240 13725 0ustar00devdev000000000000MooX-Options-4.023/t#!/usr/bin/env perl # # This file is part of MooX-Options # # This software is copyright (c) 2013 by celogeek . # # This is free software; you can redistribute it and/or modify it under # the same terms as the Perl 5 programming language system itself. # use t::Test; use Test::Trap; use Carp; use FindBin qw/$RealBin/; use Try::Tiny; BEGIN { eval 'use Mo 0.36'; if ($@) { plan skip_all => 'Need Mo (0.36) for this test'; exit 0; } } { package tRole; use Moo::Role; use Mo 'default'; use MooX::Options; option 'bool' => ( is => 'ro' ); option 'counter' => ( is => 'ro', repeatable => 1 ); option 'empty' => ( is => 'ro', negativable => 1 ); option 'split' => ( is => 'ro', format => 'i@', autosplit => ',' ); option 'has_default' => ( is => 'ro', default => sub {'foo'} ); option 'range' => ( is => 'ro', format => 'i@', autorange => 1 ); 1; } { package t; use Mo; use Role::Tiny::With; with 'tRole'; 1; } { package rRole; use Moo::Role; use Mo 'required'; use MooX::Options; option 'str_req' => ( is => 'ro', format => 's', required => 1 ); 1; } { package r; use Mo; use Role::Tiny::With; with 'rRole'; 1; } { package sp_strRole; use Moo::Role; use Mo; use MooX::Options; option 'split_str' => ( is => 'ro', format => 's', autosplit => "," ); option 'split_conflict_str1' => ( is => 'ro', format => 's', autosplit => "," ); option 'split_conflict_str2' => ( is => 'ro', format => 's', autosplit => "," ); 1; } { package sp_str; use Mo; use Role::Tiny::With; with 'sp_strRole'; 1; } { package sp_str_shortRole; use Moo::Role; use Mo; use MooX::Options; option 'split_str' => ( is => 'ro', format => 's', autosplit => ",", short => 'z' ); 1; } { package sp_str_short; use Mo; use Role::Tiny::With; with 'sp_str_shortRole'; 1; } { package dRole; use Moo::Role; use Mo 'coerce'; use MooX::Options; option 'should_die_ok' => ( is => 'ro', coerce => sub { die "this will die ok" } ); 1; } { package d; use Mo 'coerce'; use Role::Tiny::With; with 'dRole'; 1; } { package multi_reqRole; use Moo::Role; use Mo 'required'; use MooX::Options; option 'multi_1' => ( is => 'ro', required => 1 ); option 'multi_2' => ( is => 'ro', required => 1 ); option 'multi_3' => ( is => 'ro', required => 1 ); 1; } { package multi_req; use Mo; use Role::Tiny::With; with 'multi_reqRole'; 1; } { package t_docRole; use Moo::Role; use Mo; use MooX::Options; option 't' => ( is => 'ro', doc => 'this is a test' ); 1; } { package t_doc; use Mo; use Role::Tiny::With; with 't_docRole'; 1; } { package t_shortRole; use Moo::Role; use Mo; use MooX::Options; option 'verbose' => ( is => 'ro', short => 'v' ); 1; } { package t_short; use Mo; use Role::Tiny::With; with 't_shortRole'; 1; } { package t_skipoptRole; use Moo::Role; use Mo; use MooX::Options skip_options => [qw/multi/]; option 'multi' => ( is => 'ro' ); 1; } { package t_skipopt; use Mo; use Role::Tiny::With; with 't_skipoptRole'; 1; } { package t_prefer_cliRole; use Moo::Role; use Mo; use MooX::Options prefer_commandline => 1; option 't' => ( is => 'ro', format => 's' ); 1; } { package t_prefer_cli; use Mo; use Role::Tiny::With; with 't_prefer_cliRole'; 1; } { package t_dashRole; use Moo::Role; use Mo; use MooX::Options; option 'start_date' => ( is => 'ro', format => 's', short => 's' ); 1; } { package t_dash; use Mo; use Role::Tiny::With; with 't_dashRole'; 1; } { package t_jsonRole; use Moo::Role; use Mo; use MooX::Options; option 't' => ( is => 'ro', json => 1 ); 1; } { package t_json; use Mo; use Role::Tiny::With; with 't_jsonRole'; 1; } { package t_jsonOptRole; use Moo::Role; use Mo; use MooX::Options; option 't' => ( is => 'ro', format => 'json' ); 1; } { package t_json_opt; use Mo; use Role::Tiny::With; with 't_jsonOptRole'; 1; } { package rg_strRole; use Moo::Role; use Mo; use MooX::Options; option 'range_str' => ( is => 'ro', format => 's', autorange => 1 ); option 'range_conflict_str1' => ( is => 'ro', format => 's', autorange => 1 ); option 'range_conflict_str2' => ( is => 'ro', format => 's', autorange => 1 ); 1; } { package rg_str; use Mo; use Role::Tiny::With; with 'rg_strRole'; 1; } { package rg_str_shortRole; use Moo::Role; use Mo; use MooX::Options; option 'range_str' => ( is => 'ro', format => 's', autorange => 1, short => 'r' ); 1; } { package rg_str_short; use Mo; use Role::Tiny::With; with 'rg_str_shortRole'; 1; } subtest "Mo" => sub { note "Test Mo"; require $RealBin . '/base.st'; }; done_testing; MooX-Options-4.023000755001751001751 012741266240 12562 5ustar00devdev000000000000README100644001751001751 61212741266240 13502 0ustar00devdev000000000000MooX-Options-4.023 This archive contains the distribution MooX-Options, version 4.023: Explicit Options eXtension for Object Class This software is copyright (c) 2013 by celogeek . This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. This README file was generated by Dist::Zilla::Plugin::Readme v5.036. Changes100644001751001751 2331212741266240 14157 0ustar00devdev000000000000MooX-Options-4.0234.023 2016-07-12 22:19:00 GMT * Bug Github #55 : Fix error reporting on missing required arguments with Moo 2.002002. (intrigeri) * Bug #513 : remove perl 5.10 deps (Celogeek San) 4.022 2015-11-30 11:56:47 GMT * Bug #501 : Remove useless space (Celogeek San) 4.021 2015-11-11 16:42:01 GMT * Feature #487 : Translate using Locale::TextDomain (sschober) add setlocale for linux system 4.020 2015-11-08 17:33:34 GMT * Feature #487 : Translate using Locale::TextDomain (sschober) fix LC_ALL in tests 4.019 2015-10-31 16:01:55 GMT * Bug #496 : Handle multiple autosplit options correctly (Celogeek San) * Feature #489 : add compact help (Celogeek San) * Feature #487 : Translate using Locale::TextDomain (sschober) * Feature #486 : Reduce runtime dependency footprint (arc) * Feature #481 : add spacer option (Celogeek San) * Feature #373 : use "format" => "json" instead of json => 1 (Celogeek San) 4.018 2015-03-05 07:07:03 GMT * Feature #475 : Add usage_string parameters (kablamo) 4.017 2015-02-13 07:13:03 GMT * Bug #472 : Upgrade deps on Module::Build and Getopt::Long (Celogeek San) 4.016 2015-01-24 12:30:10 GMT * Feature #470 : Add "hidden" attribute, and doc (Celogeek San) * Feature #471 : Added a better error message for isa check failures (Celogeek San) 4.015 2015-01-13 16:06:52 GMT * Bug #466 : Term::Any::Size should be recommanded but optional (Celogeek San) fix eval 4.014 2015-01-13 15:51:32 GMT * Bug #464 : warning generated when missing required params (Celogeek San) * Bug #466 : Term::Any::Size should be recommanded but optional (Celogeek San) 4.013 2014-11-22 07:43:13 GMT * Feature #462 : Autorange (Celogeek San) 4.012 2014-10-07 09:42:27 GMT * Bug #455 : Option of options should not be change for trait (Celogeek San) handle shorter name 4.011 2014-10-07 08:51:50 GMT * Bug #455 : Option of options should not be change for trait (Celogeek San) 4.010 2014-09-05 16:49:56 GMT * Feature #453 : Use Text::LineFold instead of Text::WrapI18N (Celogeek San) * Feature #452 : Support UTF8 source for pod and man (Celogeek San) 4.009 2014-07-08 10:15:09 GMT * Bug #450 : options with format "s" do not accept "0" as value (Celogeek San) 4.008 2014-02-01 09:49:36 GMT * Bug #405 : fix typo in pod (Celogeek San) 4.007 2014-01-17 15:57:22 GMT * Bug #403 : fix pod (Grzegorz Rożniecki) 4.006 2013-12-18 14:31:42 GMT * Bug #388 : Short option not properly fixed (fix_argv) (Celogeek San) 4.005 2013-12-16 12:44:02 GMT * Bug #383: autosplit should handle all variance of "-" and "_" Fix tests (reused vars) 4.004 2013-12-14 13:00:38 GMT * Bug #383: autosplit should handle all variance of "-" and "_" implement a proper fix_argv method 4.003 2013-12-01 00:40:22 GMT * Feature #370 : Add usage, only the usage row with all the long options (Celogeek San) 4.002 2013-11-29 19:07:32 GMT * Feature #380 : global improvement doc (Celogeek San) * Bug #378 : fix pod typo (Celogeek San) * Feature #379 : improve synopsis (Celogeek San) 4.001 2013-11-26 09:15:14 GMT * Bug #377 : older version of perl has different init methods (Celogeek San) 4.000 2013-11-25 19:01:24 GMT * Feature #328 : Rewrite pod (Celogeek San) Fix: Path::Class 0.32 needed for tempfile Fix: import only moox options role methods, not the one need by this module Fix: JSON help format Feature: improve handling of errors (catch everything and display the proper usage methods) Feature: full rewrite pod documentation 3.99 2013-11-13 09:36:51 GMT * Feature #195 : Use pod2usage for help (Celogeek San) 3.98 2013-11-10 13:03:41 GMT * Feature #369 : Add support of List of all subcommand from MooX::Cmd (Celogeek San) 3.97 2013-11-09 13:31:26 GMT * Feature #368 : Improve support of MooX::Cmd (Celogeek San) 3.96 2013-11-06 20:22:43 GMT * Feature #367 : use the command name of the MooX::Cmd if available (Celogeek San) 3.95 2013-11-06 20:06:26 GMT * Feature #366 : Support MooX::Cmd (Celogeek San) 3.94 2013-10-27 17:33:35 GMT * Feature #352 : Rewrite the option text message (Celogeek San) 3.93 2013-10-24 20:15:53 GMT * Feature #350 : Push back Mo support with proper deps (Celogeek San) 3.92 2013-10-24 16:27:01 GMT * Bug #349 : drop Mo support, it use Mouse ! (Celogeek San) 3.91 2013-10-24 16:04:05 GMT * Bug #348 : die if the caller is not able to run "around" or "with" (Celogeek San) 3.90 2013-10-14 20:30:53 GMT * Feature #338 : Add test module in test build required (Celogeek San) 3.89 2013-10-14 18:31:12 GMT * Feature #335 : Fix changes based on kwaleeti (Celogeek San) 3.88 2013-10-12 17:39:25 GMT * Feature #332 : Create real usage_option method, and use it for help message (Celogeek San) 3.87 2013-10-12 14:04:11 GMT * Bug #331 : Fix tests with Mo (Celogeek San) 3.86 2013-09-28 12:38:55 GMT * Feature #329 : Add support config file to get option (Celogeek San) 3.85 2013-09-22 16:06:32 GMT * Feature #309 : Indicate what is expected in the help message (Celogeek San) 3.84 2013-09-12 22:36:54 GMT * Bug #157 : repeatable work only with the original name (Celogeek San) 3.83 2013-05-13 12:35:06 GMT * Bug #211 : Fix README.mkdn (Celogeek San) 3.82 2013-05-13 08:40:27 GMT * Feature #158 : use GRS for release (Celogeek San) 3.81 2013-05-13 * dummy 3.80 2013-04-28 23:46:23 Europe/Paris * Bug #198 : Fix pod, issue with metacpan (Celogeek San) 3.79 2013-04-25 00:12:25 Europe/Paris * Feature #192 : support json mode (Celogeek San) 3.78 2013-04-12 01:16:12 Europe/Paris * Support for prefered commandline (Tom Lanyon) 3.77 2013-01-05 18:23:49 Europe/Paris * Support for dash in option 3.76 2012-12-24 12:47:40 Europe/Paris * Reupload due to pause failure 3.75 2012-12-24 12:46:12 Europe/Paris * Update changes 3.74 2012-12-24 12:36:12 Europe/Paris * [Keedi Kim] : Allow ordering of params (by name by default, can be selected order) 3.73 2012-12-08 20:07:07 Europe/Paris * Add deps 3.72 2012-11-26 00:47:35 Europe/Paris * Change bugtracker and git repository 3.71 2012-09-03 02:18:06 Europe/Paris 3.7 2012-09-03 02:12:10 Europe/Paris 3.6 2012-08-20 00:28:50 Europe/Paris * Fix: autosplit with space * Add: greeding and slides 3.5 2012-08-13 23:34:33 Europe/Paris * working role ! * fix namespace clean * add doc to use it 3.4 2012-08-13 20:34:17 Europe/Paris * disabling failing test * moo is now a necessary deps 3.3 2012-08-13 10:38:16 Europe/Paris * support for namespace::clean * fix issue with default value * move ski_options to the role * move options_meta and options_params to the main package * fix role issues * TODO: make role fully work 3.2 2012-08-12 14:41:26 Europe/Paris * add option skip_options to remove option to the terminal 3.1 2012-08-12 02:45:07 Europe/Paris * Fix is missing 3.0 2012-08-12 02:06:35 Europe/Paris * Full rewrite of MooX::Options * Add easy support to use it in a Role. * Break support of Mouse. 2.4 2012-07-27 02:06:03 Europe/Paris * Fix: Role, wasn't working very well 2.3 2012-07-25 18:48:47 Europe/Paris * Add MooX::Options::Role - You can create role in your module that automatically call MooX::Option 'option' method when the role is imported. 2.2 2012-07-19 12:52:59 Europe/Paris * Fix test for Moo 1.0 2.1 2012-07-17 18:11:38 Europe/Paris * Fix pod 2.0 2012-07-17 18:04:48 Europe/Paris * Add 'documentation', an alternative 'doc' option attribute 1.9 2012-07-17 15:02:42 Europe/Paris * Remove bugs section (duplicate) 1.8 2012-07-16 16:51:44 Europe/Paris * use Dist::Zilla::PluginBundle::Author::Celogeek v0.7 1.7 2012-07-16 14:55:02 Europe/Paris * use Dist::Zilla::PluginBundle::Author::Celogeek 1.6 2012-06-08 11:20 * Change author name 1.5 2012-06-01 01:10 * fix mouse test * add doc, markdown, cleanup 1.4 2012-05-16 23:30 * remove goto method, compat with older perl 1.3 2012-05-12 00:30 * fix minimum version to 5.8.9 * fix test unit 1.2 2012-05-02 02:20 * add advice on repeatable option (Alex Howarth) * full test and 100% coverage * fix import_options and add protection. 1.1 2012-03-13 23:20 * remove min version for testing Moo * remove deps on Mo/Moo/Mouse/Moose from test (if present do the test, else skip) 1.0 2012-03-10 16:00 * use perl 5.006 syntax compatible, allow use MooX::Options with older version 0.9 2012-02-14 21:40 * Add flavour to pass options to GetOpt::Long (zengargoyle) 0.8 2011-12-25 14:30 * use Moo 0.009013 to pass cpantester tests 0.7 2011-12-09 00:10 * change name to MooX::Options * fix Global name (UPPERCASE) * fix Global name (Camel_Case) * fix private name (no more "_") 0.6 2011-12-04 13:00 * add option_usage * add test for it 0.5 2011-12-04 12:20 * fix doc 0.4 2011-12-04 12:00 * fix call chain method (don't call properly because new method was not already generated at the call) * add test for chain_method (should_die_ok) 0.3 2011-12-03 13:00 * fix test unit 0.2 2011-12-02 01:30 * improve help test * fix possible miss reading * Factorize test import_options rename options for import_options (better reading) remove synopsis filter is on by default, can be cancel with \"nofilter\" import doc at the end * add TODO * fix tests for autosplit, add complex autosplit for str with quote * add some better handle of repeatable and negativable, use Data::Record to resplit the args 0.1 2011-11-30 18:30 * First release of MooX::Getopt * Fully compatible with Mo/Moo/Mouse/Moose and more doc.t100644001751001751 403312741266240 14040 0ustar00devdev000000000000MooX-Options-4.023/t#!perl # # This file is part of MooX-Options # # This software is copyright (c) 2013 by celogeek . # # This is free software; you can redistribute it and/or modify it under # the same terms as the Perl 5 programming language system itself. # use t::Test; use Test::Trap; use Carp; use FindBin qw/$RealBin/; use Try::Tiny; local $ENV{TEST_FORCE_COLUMN_SIZE} = 78; { package t; use Moo; use MooX::Options; option 't' => ( is => 'ro', documentation => 'this is a test', ); 1; } { package t1; use Moo; use MooX::Options; option 't' => ( is => 'ro', doc => 'this pass first', documentation => 'this is a test', ); 1; } { package t2; use Moo; use t::Test; sub filter_opt { my ( $attr, %opt ) = @_; ok !defined $opt{doc}, 'doc has been filtered'; ok defined $opt{documentation}, 'documentation has been keeped'; return has( $attr, %opt ); } use MooX::Options option_chain_method => 'filter_opt'; option 't' => ( is => 'ro', doc => 'this pass first', documentation => 'this is a test', ); 1; } { my $opt = t->new_with_options; trap { $opt->options_usage }; like $trap->stdout, qr/\s+\-t\s+this\sis\sa\stest/x, 'documentation work'; trap { $opt->options_help }; like $trap->stdout, qr/\s+\-t:\n\s+this\sis\sa\stest/x, 'documentation work'; } { my $opt = t1->new_with_options; trap { $opt->options_usage }; like $trap->stdout, qr/\s+\-t\s+this\spass\sfirst/x, 'doc pass first'; trap { $opt->options_help }; like $trap->stdout, qr/\s+\-t:\n\s+this\spass\sfirst/x, 'doc pass first'; } { my $opt = t2->new_with_options; trap { $opt->options_usage }; like $trap->stdout, qr/\s+\-t\s+this\spass\sfirst/x, 'doc pass first'; trap { $opt->options_help }; like $trap->stdout, qr/\s+\-t:\n\s+this\spass\sfirst/x, 'doc pass first'; } done_testing; pod.t100644001751001751 106012741266240 14052 0ustar00devdev000000000000MooX-Options-4.023/t#!perl # # This file is part of MooX-Options # # This software is copyright (c) 2013 by celogeek . # # This is free software; you can redistribute it and/or modify it under # the same terms as the Perl 5 programming language system itself. # use t::Test; use warnings FATAL => 'all'; unless ( $ENV{RELEASE_TESTING} ) { plan( skip_all => 'these tests are for release candidate testing' ); } use English qw( -no_match_vars ); local $OUTPUT_AUTOFLUSH = 1; use Test::Requires { 'Test::Pod' => 1.46 }; all_pod_files_ok(); done_testing(); moo.t100644001751001751 641412741266240 14072 0ustar00devdev000000000000MooX-Options-4.023/t#!/usr/bin/env perl # # This file is part of MooX-Options # # This software is copyright (c) 2013 by celogeek . # # This is free software; you can redistribute it and/or modify it under # the same terms as the Perl 5 programming language system itself. # use t::Test; use Test::Trap; use Carp; use FindBin qw/$RealBin/; use Try::Tiny; { package t; use Moo; use MooX::Options; option 'bool' => ( is => 'ro' ); option 'counter' => ( is => 'ro', repeatable => 1 ); option 'empty' => ( is => 'ro', negativable => 1 ); option 'split' => ( is => 'ro', format => 'i@', autosplit => ',' ); option 'has_default' => ( is => 'ro', default => sub {'foo'} ); option 'range' => ( is => 'ro', format => 'i@', autorange => 1 ); 1; } { package r; use Moo; use MooX::Options; option 'str_req' => ( is => 'ro', format => 's', required => 1 ); 1; } { package sp_str; use Moo; use MooX::Options; option 'split_str' => ( is => 'ro', format => 's', autosplit => "," ); option 'split_conflict_str1' => ( is => 'ro', format => 's', autosplit => "," ); option 'split_conflict_str2' => ( is => 'ro', format => 's', autosplit => "," ); 1; } { package sp_str_short; use Moo; use MooX::Options; option 'split_str' => ( is => 'ro', format => 's', autosplit => ",", short => 'z' ); 1; } { package d; use Moo; use MooX::Options; option 'should_die_ok' => ( is => 'ro', isa => sub { die "this will die ok" } ); 1; } { package multi_req; use Moo; use MooX::Options; option 'multi_1' => ( is => 'ro', required => 1 ); option 'multi_2' => ( is => 'ro', required => 1 ); option 'multi_3' => ( is => 'ro', required => 1 ); 1; } { package t_doc; use Moo; use MooX::Options; option 't' => ( is => 'ro', doc => 'this is a test' ); 1; } { package t_short; use Moo; use MooX::Options; option 'verbose' => ( is => 'ro', short => 'v' ); 1; } { package t_skipopt; use Moo; use MooX::Options skip_options => [qw/multi/]; option 'multi' => ( is => 'ro' ); 1; } { package t_prefer_cli; use Moo; use MooX::Options prefer_commandline => 1; option 't' => ( is => 'ro', format => 's' ); 1; } { package t_dash; use Moo; use MooX::Options; option 'start_date' => ( is => 'ro', format => 's', short => 's' ); 1; } { package t_json; use Moo; use MooX::Options; option 't' => ( is => 'ro', json => 1 ); 1; } { package t_json_opt; use Moo; use MooX::Options; option 't' => ( is => 'ro', format => 'json' ); 1; } { package rg_str; use Moo; use MooX::Options; option 'range_str' => ( is => 'ro', format => 's', autorange => 1 ); option 'range_conflict_str1' => ( is => 'ro', format => 's', autorange => 1 ); option 'range_conflict_str2' => ( is => 'ro', format => 's', autorange => 1 ); 1; } { package rg_str_short; use Moo; use MooX::Options; option 'range_str' => ( is => 'ro', format => 's', autorange => 1, short => 'r' ); 1; } subtest "Moo" => sub { note "Test Moo"; require $RealBin . '/base.st'; }; done_testing; LICENSE100644001751001751 4372712741266240 13705 0ustar00devdev000000000000MooX-Options-4.023This software is copyright (c) 2013 by celogeek . 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) 2013 by celogeek . 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) 2013 by celogeek . This is free software, licensed under: The Artistic License 1.0 The Artistic License Preamble The intent of this document is to state the conditions under which a Package may be copied, such that the Copyright Holder maintains some semblance of artistic control over the development of the package, while giving the users of the package the right to use and distribute the Package in a more-or-less customary fashion, plus the right to make reasonable modifications. Definitions: - "Package" refers to the collection of files distributed by the Copyright Holder, and derivatives of that collection of files created through textual modification. - "Standard Version" refers to such a Package if it has not been modified, or has been modified in accordance with the wishes of the Copyright Holder. - "Copyright Holder" is whoever is named in the copyright or copyrights for the package. - "You" is you, if you're thinking about copying or distributing this Package. - "Reasonable copying fee" is whatever you can justify on the basis of media cost, duplication charges, time of people involved, and so on. (You will not be required to justify it to the Copyright Holder, but only to the computing community at large as a market that must bear the fee.) - "Freely Available" means that no fee is charged for the item itself, though there may be fees involved in handling the item. It also means that recipients of the item may redistribute it under the same conditions they received it. 1. You may make and give away verbatim copies of the source form of the Standard Version of this Package without restriction, provided that you duplicate all of the original copyright notices and associated disclaimers. 2. You may apply bug fixes, portability fixes and other modifications derived from the Public Domain or from the Copyright Holder. A Package modified in such a way shall still be considered the Standard Version. 3. You may otherwise modify your copy of this Package in any way, provided that you insert a prominent notice in each changed file stating how and when you changed that file, and provided that you do at least ONE of the following: a) place your modifications in the Public Domain or otherwise make them Freely Available, such as by posting said modifications to Usenet or an equivalent medium, or placing the modifications on a major archive site such as ftp.uu.net, or by allowing the Copyright Holder to include your modifications in the Standard Version of the Package. b) use the modified Package only within your corporation or organization. c) rename any non-standard executables so the names do not conflict with standard executables, which must also be provided, and provide a separate manual page for each non-standard executable that clearly documents how it differs from the Standard Version. d) make other distribution arrangements with the Copyright Holder. 4. You may distribute the programs of this Package in object code or executable form, provided that you do at least ONE of the following: a) distribute a Standard Version of the executables and library files, together with instructions (in the manual page or equivalent) on where to get the Standard Version. b) accompany the distribution with the machine-readable source of the Package with your modifications. c) accompany any non-standard executables with their corresponding Standard Version executables, giving the non-standard executables non-standard names, and clearly documenting the differences in manual pages (or equivalent), together with instructions on where to get the Standard Version. d) make other distribution arrangements with the Copyright Holder. 5. You may charge a reasonable copying fee for any distribution of this Package. You may charge any fee you choose for support of this Package. You may not charge a fee for this Package itself. However, you may distribute this Package in aggregate with other (possibly commercial) programs as part of a larger (possibly commercial) software distribution provided that you do not advertise this Package as a product of your own. 6. The scripts and library files supplied as input to or produced as output from the programs of this Package do not automatically fall under the copyright of this Package, but belong to whomever generated them, and may be sold commercially, and may be aggregated with this Package. 7. C or perl subroutines supplied by you and linked into this Package shall not be considered part of this Package. 8. The name of the Copyright Holder may not be used to endorse or promote products derived from this software without specific prior written permission. 9. THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. The End dist.ini100644001751001751 150512741266240 14310 0ustar00devdev000000000000MooX-Options-4.023name = MooX-Options license = Perl_5 copyright_holder = celogeek copyright_year = 2013 version = 4.023 [@GRS] -remove = AutoPrereqs -remove = Prereqs -remove = MetaResourcesFromGit -remove = ModuleBuild [ModuleBuild] mb_version = 0.4211 [AutoPrereqs] skip = Role$|^Moose$|^Mo$|^MooX::Cmd$ [Prereqs] Moo = 1.003001 Module::Metadata = 1.000019 MooX::ConfigFromFile = 0 [Prereqs / RuntimeRecommends] Term::Size::Any=0 [MetaResourcesFromGit] homepage = https://tasks.celogeek.com/projects/perl-modules-moox-options bugtracker.web = https://github.com/celogeek/MooX-Options/issues repository.url = https://github.com/celogeek/MooX-Options.git repository.web = https://github.com/celogeek/MooX-Options repository.type = git ;[Test::Pod::LinkCheck] ;[Test::Pod::No404s] [LocaleTextDomain] textdomain = MooX-Options role.t100644001751001751 375712741266240 14250 0ustar00devdev000000000000MooX-Options-4.023/t#!perl # # This file is part of MooX-Options # # This software is copyright (c) 2013 by celogeek . # # This is free software; you can redistribute it and/or modify it under # the same terms as the Perl 5 programming language system itself. # use t::Test; use Test::Trap; local $ENV{TEST_FORCE_COLUMN_SIZE} = 78; { package myRole; use strict; use warnings; use Moo::Role; use MooX::Options; option 'multi' => ( is => 'rw', doc => 'multi threading mode' ); 1; } { package testRole; use Moo; use MooX::Options; with 'myRole'; 1; } { package testRole2; use Moo; use MooX::Options skip_options => undef; with 'myRole'; 1; } { package testSkipOpt; use Moo; use MooX::Options skip_options => [qw/multi/], flavour => [qw( pass_through )]; with 'myRole'; 1; } { local @ARGV; @ARGV = (); my $opt = testRole->new_with_options; ok( !$opt->multi, 'multi not set' ); } { local @ARGV; @ARGV = ('--multi'); my $opt = testRole->new_with_options; ok( $opt->multi, 'multi set' ); trap { $opt->options_usage; }; like( $trap->stdout, qr/\-\-multi\s+multi\sthreading\smode/x, "usage method is properly set" ); } { local @ARGV; @ARGV = (); my $opt = testRole2->new_with_options; ok( !$opt->multi, 'multi not set' ); } { local @ARGV; @ARGV = ('--multi'); my $opt = testRole2->new_with_options; ok( $opt->multi, 'multi set' ); trap { $opt->options_usage; }; like( $trap->stdout, qr/\-\-multi\s+multi\sthreading\smode/x, "usage method is properly set" ); } { local @ARGV; @ARGV = ('--multi'); my $opt = testSkipOpt->new_with_options; ok( !$opt->multi, 'multi not set' ); trap { $opt->options_usage; }; ok( $trap->stdout !~ /\-\-multi\s+multi\sthreading\smode/x, "usage method is properly set" ); } done_testing; 1; po000755001751001751 012741266240 13121 5ustar00devdev000000000000MooX-Options-4.023de.po100644001751001751 731212741266240 14214 0ustar00devdev000000000000MooX-Options-4.023/po# German translations for MooX-Options package. # Copyright (C) 2015 celogeek # This file is distributed under the same license as the MooX-Options package. # Automatically generated, 2015. # msgid "" msgstr "" "Project-Id-Version: MooX-Options 4.009\n" "Report-Msgid-Bugs-To: me@celogeek.com\n" "POT-Creation-Date: 2015-05-01 13:45+0400\n" "PO-Revision-Date: 2015-05-01 13:46+0400\n" "Last-Translator: Automatically generated\n" "Language-Team: none\n" "Language: de\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=ASCII\n" "Content-Transfer-Encoding: 8bit\n" "Plural-Forms: nplurals=2; plural=(n != 1);\n" "X-Generator: Poedit 1.7.4\n" #: lib/MooX/Options.pm:102 #, perl-brace-format msgid "" "Can't find the method <{needed_methods}> in <{target}> ! Ensure to load a " "Role::Tiny compatible module like Moo or Moose before using MooX::Options." msgstr "" "Kann die Methode <{needed_methods}> nicht in <{target}> finden! Stellen Sie " "sicher, dass ein Role::Tiny kompatibles Modul, wie Moo oder Moose geladen " "ist, bevor Sie MooX::Options benutzen." #: lib/MooX/Options.pm:147 msgid "Please, don't use the option into a role." msgstr "" "Bitte, komponieren Sie die Option nicht in eine " "Rolle." #: lib/MooX/Options.pm:191 #, perl-brace-format msgid "" "You cannot use an option with the name '{ban}', it is implied by MooX::" "Options" msgstr "" "Sie koennen eine Option mit Namen '{ban}' nicht einsetzen, da diese bereits " "von MooX::Options impliziert wird." #: lib/MooX/Options.pm:250 msgid "" "Negativable params is not usable with non boolean value, don't pass format " "to use it !" msgstr "" "Ungueltige Formatspezifikation. Negierbare Parameter sind mit Bool'schen " "Werten nicht einsetzbar." #: lib/MooX/Options/Descriptive/Usage.pm:38 #: lib/MooX/Options/Descriptive/Usage.pm:51 msgid "String" msgstr "Zeichenkette" #: lib/MooX/Options/Descriptive/Usage.pm:39 msgid "[Strings]" msgstr "[Zeichenketten]" #: lib/MooX/Options/Descriptive/Usage.pm:40 msgid "Int" msgstr "Ganzzahl" #: lib/MooX/Options/Descriptive/Usage.pm:41 msgid "[Ints]" msgstr "[Ganzzahlen]" #: lib/MooX/Options/Descriptive/Usage.pm:42 msgid "Ext. Int" msgstr "Erw. Ganzzahl" #: lib/MooX/Options/Descriptive/Usage.pm:43 msgid "[Ext. Ints]" msgstr "[Erw. Ganzzahl]" #: lib/MooX/Options/Descriptive/Usage.pm:44 msgid "Real" msgstr "Reelle Zahl" #: lib/MooX/Options/Descriptive/Usage.pm:45 msgid "[Reals]" msgstr "[Reelle Zahlen]" #: lib/MooX/Options/Descriptive/Usage.pm:52 msgid "Array of Strings" msgstr "Array von Zeichenketten" #: lib/MooX/Options/Descriptive/Usage.pm:53 msgid "Integer" msgstr "Ganzzahl" #: lib/MooX/Options/Descriptive/Usage.pm:54 msgid "Array of Integers" msgstr "" #: lib/MooX/Options/Descriptive/Usage.pm:55 msgid "Extended Integer" msgstr "Erweiterte Ganzzahl" #: lib/MooX/Options/Descriptive/Usage.pm:56 msgid "Array of extended integers" msgstr "" #: lib/MooX/Options/Descriptive/Usage.pm:57 msgid "Real number" msgstr "Reelle Zahl" #: lib/MooX/Options/Descriptive/Usage.pm:58 msgid "Array of real numbers" msgstr "" #: lib/MooX/Options/Descriptive/Usage.pm:113 msgid "SUB COMMANDS AVAILABLE: " msgstr "Unterkommandos verfuegbar" #: lib/MooX/Options/Descriptive/Usage.pm:211 #: lib/MooX/Options/Descriptive/Usage.pm:250 msgid "long options ..." msgstr "Langoptionen ..." #: lib/MooX/Options/Role.pm:314 #, perl-format, perl-brace-format msgid "USAGE: {prog_name} %o" msgstr "Aufruf: {prog_name} %o" #: lib/MooX/Options/Role.pm:320 msgid "show a short help message" msgstr "Ein kurzer Hilfetext" #: lib/MooX/Options/Role.pm:321 msgid "show a help message" msgstr "Zeige einen Hilfetext" #: lib/MooX/Options/Role.pm:322 msgid "show the manual" msgstr "Zeige das Handbuch" META.yml100644001751001751 2172412741266240 14142 0ustar00devdev000000000000MooX-Options-4.023--- abstract: 'Explicit Options eXtension for Object Class' author: - 'celogeek ' build_requires: Capture::Tiny: '0' English: '0' File::Spec: '0' FindBin: '0' IO::Handle: '0' IPC::Open3: '0' Import::Into: '0' Module::Build: '0.4211' Moo: '1.003001' POSIX: '0' Role::Tiny::With: '0' Test::More: '0.94' Test::Requires: '0' Test::Trap: '0' Try::Tiny: '0' lib: '0' namespace::clean: '0' perl: '5.006' configure_requires: Module::Build: '0.4211' perl: '5.006' dynamic_config: 0 generated_by: 'Dist::Zilla version 5.036, CPAN::Meta::Converter version 2.150001' license: perl meta-spec: url: http://module-build.sourceforge.net/META-spec-v1.4.html version: '1.4' name: MooX-Options recommends: Term::Size::Any: '0' requires: Carp: '0' Data::Record: '0' Getopt::Long: '2.43' Getopt::Long::Descriptive: '0.099' JSON::MaybeXS: '0' Locale::TextDomain: '0' Module::Metadata: '1.000019' Moo: '1.003001' MooX::ConfigFromFile: '0' Path::Class: '0.32' Pod::Usage: '0' Regexp::Common: '0' Scalar::Util: '0' Term::Size::Any: '0' Text::LineFold: '0' overload: '0' parent: '0' perl: '5.006' strict: '0' warnings: '0' resources: bugtracker: https://github.com/celogeek/MooX-Options/issues homepage: https://tasks.celogeek.com/projects/perl-modules-moox-options repository: https://github.com/celogeek/MooX-Options.git version: '4.023' x_Dist_Zilla: perl: version: '5.020003' plugins: - class: Dist::Zilla::Plugin::GatherDir config: Dist::Zilla::Plugin::GatherDir: exclude_filename: [] exclude_match: [] follow_symlinks: '0' include_dotfiles: '0' prefix: '' prune_directory: [] root: . name: '@GRS/@Filter/GatherDir' version: '5.036' - class: Dist::Zilla::Plugin::PruneCruft name: '@GRS/@Filter/PruneCruft' version: '5.036' - class: Dist::Zilla::Plugin::ManifestSkip name: '@GRS/@Filter/ManifestSkip' version: '5.036' - class: Dist::Zilla::Plugin::MetaYAML name: '@GRS/@Filter/MetaYAML' version: '5.036' - class: Dist::Zilla::Plugin::License name: '@GRS/@Filter/License' version: '5.036' - class: Dist::Zilla::Plugin::Readme name: '@GRS/@Filter/Readme' version: '5.036' - class: Dist::Zilla::Plugin::ExtraTests name: '@GRS/@Filter/ExtraTests' version: '5.036' - class: Dist::Zilla::Plugin::ExecDir name: '@GRS/@Filter/ExecDir' version: '5.036' - class: Dist::Zilla::Plugin::ShareDir name: '@GRS/@Filter/ShareDir' version: '5.036' - class: Dist::Zilla::Plugin::Manifest name: '@GRS/@Filter/Manifest' version: '5.036' - class: Dist::Zilla::Plugin::TestRelease name: '@GRS/@Filter/TestRelease' version: '5.036' - class: Dist::Zilla::Plugin::ConfirmRelease name: '@GRS/@Filter/ConfirmRelease' version: '5.036' - class: Dist::Zilla::Plugin::ReportVersions name: '@GRS/ReportVersions' version: '1.110730' - class: Dist::Zilla::Plugin::OurPkgVersion name: '@GRS/OurPkgVersion' version: '0.06' - class: Dist::Zilla::Plugin::Prepender name: '@GRS/Prepender' version: '2.001' - class: Dist::Zilla::Plugin::MinimumPerl name: '@GRS/MinimumPerl' version: '1.006' - class: Dist::Zilla::Plugin::Test::Compile config: Dist::Zilla::Plugin::Test::Compile: bail_out_on_fail: '0' fail_on_warning: author fake_home: '0' filename: t/00-compile.t module_finder: - ':InstallModules' needs_display: '0' phase: test script_finder: - ':ExecFiles' skips: [] name: '@GRS/Test::Compile' version: '2.053' - class: Dist::Zilla::Plugin::Test::UnusedVars name: '@GRS/Test::UnusedVars' version: '2.000007' - class: Dist::Zilla::Plugin::PodCoverageTests name: '@GRS/PodCoverageTests' version: '5.036' - class: Dist::Zilla::Plugin::PruneFiles name: '@GRS/PruneFiles' version: '5.036' - class: Dist::Zilla::Plugin::ReadmeMarkdownFromPod name: '@GRS/ReadmeMarkdownFromPod' version: '0.141140' - class: Dist::Zilla::Plugin::MetaJSON name: '@GRS/MetaJSON' version: '5.036' - class: Dist::Zilla::Plugin::MetaConfig name: '@GRS/MetaConfig' version: '5.036' - class: Dist::Zilla::Plugin::PodWeaver config: Dist::Zilla::Plugin::PodWeaver: config_plugins: - '@GRS' finder: - ':InstallModules' - ':ExecFiles' plugins: - class: Pod::Weaver::Plugin::EnsurePod5 name: '@CorePrep/EnsurePod5' version: '4.012' - class: Pod::Weaver::Plugin::H1Nester name: '@CorePrep/H1Nester' version: '4.012' - class: Pod::Weaver::Section::Name name: '@Default/Name' version: '4.012' - class: Pod::Weaver::Section::Version name: '@Default/Version' version: '4.012' - class: Pod::Weaver::Section::Region name: '@Default/prelude' version: '4.012' - class: Pod::Weaver::Section::Generic name: DESCRIPTION version: '4.012' - class: Pod::Weaver::Section::Generic name: SYNOPSIS version: '4.012' - class: Pod::Weaver::Section::Generic name: OVERVIEW version: '4.012' - class: Pod::Weaver::Section::Collect name: ATTRIBUTES version: '4.012' - class: Pod::Weaver::Section::Collect name: METHODS version: '4.012' - class: Pod::Weaver::Section::Collect name: FUNCTIONS version: '4.012' - class: Pod::Weaver::Section::Leftovers name: '@Default/Leftovers' version: '4.012' - class: Pod::Weaver::Section::Region name: '@Default/postlude' version: '4.012' - class: Pod::Weaver::Section::Bugs name: '@Default/Bugs' version: '4.012' - class: Pod::Weaver::Section::Authors name: '@Default/Authors' version: '4.012' - class: Pod::Weaver::Section::Legal name: '@Default/Legal' version: '4.012' name: '@GRS/PodWeaver' version: '4.006' - class: Dist::Zilla::Plugin::PerlTidy name: '@GRS/PerlTidy' version: '0.21' - class: Dist::Zilla::Plugin::Test::Perl::Critic name: '@GRS/Test::Perl::Critic' version: '3.000' - class: Dist::Zilla::Plugin::Test::Kwalitee::Extra name: '@GRS/Test::Kwalitee::Extra' version: v0.2.1 - class: Dist::Zilla::Plugin::ModuleBuild config: Dist::Zilla::Role::TestRunner: default_jobs: 1 name: ModuleBuild version: '5.036' - class: Dist::Zilla::Plugin::AutoPrereqs name: AutoPrereqs version: '5.036' - class: Dist::Zilla::Plugin::Prereqs config: Dist::Zilla::Plugin::Prereqs: phase: runtime type: requires name: Prereqs version: '5.036' - class: Dist::Zilla::Plugin::Prereqs config: Dist::Zilla::Plugin::Prereqs: phase: runtime type: recommends name: RuntimeRecommends version: '5.036' - class: Dist::Zilla::Plugin::MetaResourcesFromGit name: MetaResourcesFromGit version: '1.103620' - class: Dist::Zilla::Plugin::LocaleTextDomain name: LocaleTextDomain version: '0.90' - class: Dist::Zilla::Plugin::FinderCode name: ':InstallModules' version: '5.036' - class: Dist::Zilla::Plugin::FinderCode name: ':IncModules' version: '5.036' - class: Dist::Zilla::Plugin::FinderCode name: ':TestFiles' version: '5.036' - class: Dist::Zilla::Plugin::FinderCode name: ':ExecFiles' version: '5.036' - class: Dist::Zilla::Plugin::FinderCode name: ':ShareFiles' version: '5.036' - class: Dist::Zilla::Plugin::FinderCode name: ':MainModule' version: '5.036' - class: Dist::Zilla::Plugin::FinderCode name: ':AllFiles' version: '5.036' - class: Dist::Zilla::Plugin::FinderCode name: ':NoFiles' version: '5.036' zilla: class: Dist::Zilla::Dist::Builder config: is_trial: '0' version: '5.036' MANIFEST100644001751001751 244112741266240 13775 0ustar00devdev000000000000MooX-Options-4.023# This file was automatically generated by Dist::Zilla::Plugin::Manifest v5.036. Build.PL Changes LICENSE MANIFEST META.json META.yml README README.mkdn coverage.txt dist.ini etc/with_config.t.json etc/with_config_2.t.json lib/MooX/Options.pm lib/MooX/Options/Descriptive.pm lib/MooX/Options/Descriptive/Usage.pm lib/MooX/Options/Manual/Man.pod lib/MooX/Options/Manual/MooXCmd.pod lib/MooX/Options/Manual/NamespaceClean.pod lib/MooX/Options/Role.pm po/MooX-Options.pot po/de.po po/de_DE.po share/LocaleData/de/LC_MESSAGES/MooX-Options.mo share/LocaleData/de_DE/LC_MESSAGES/MooX-Options.mo t/00-compile.t t/000-report-versions.t t/Test.pm t/around_options_usage.t t/author-critic.t t/autosplit_warning_on_required_param.t t/base.st t/check_target_methods.t t/doc-utf8.t t/doc.t t/failure.t t/flavour.t t/hidden.t t/isa_check.t t/lib/MooXCmdTest.pm t/lib/MooXCmdTest/Cmd/test1.pm t/lib/MooXCmdTest/Cmd/test1/Cmd/test2.pm t/lib/MooXCmdTest/Cmd/test3.pm t/lib/TestNamespaceClean.pm t/mo.t t/moo.t t/moose.t t/moox-cmd.t t/multi_role.t t/multiple-split-options.t t/namespace_clean.t t/no_option.t t/option-of-option.t t/order.t t/pod.t t/release-kwalitee.t t/release-pod-coverage.t t/release-unused-vars.t t/role.t t/spacer.t t/string_with_zero_value.t t/usage_string.t t/with_config.t xt/perlcritic.rc xt/perltidy.rc Build.PL100644001751001751 511212741266240 14136 0ustar00devdev000000000000MooX-Options-4.023# # This file is part of MooX-Options # # This software is copyright (c) 2013 by celogeek . # # This is free software; you can redistribute it and/or modify it under # the same terms as the Perl 5 programming language system itself. # # This file was automatically generated by Dist::Zilla::Plugin::ModuleBuild v5.036. use strict; use warnings; use Module::Build 0.4211; my %module_build_args = ( "build_requires" => { "Module::Build" => "0.4211" }, "configure_requires" => { "Module::Build" => "0.4211", "perl" => "5.006" }, "dist_abstract" => "Explicit Options eXtension for Object Class", "dist_author" => [ "celogeek " ], "dist_name" => "MooX-Options", "dist_version" => "4.023", "license" => "perl", "module_name" => "MooX::Options", "recommends" => { "Term::Size::Any" => 0 }, "recursive_test_files" => 1, "requires" => { "Carp" => 0, "Data::Record" => 0, "Getopt::Long" => "2.43", "Getopt::Long::Descriptive" => "0.099", "JSON::MaybeXS" => 0, "Locale::TextDomain" => 0, "Module::Metadata" => "1.000019", "Moo" => "1.003001", "MooX::ConfigFromFile" => 0, "Path::Class" => "0.32", "Pod::Usage" => 0, "Regexp::Common" => 0, "Scalar::Util" => 0, "Term::Size::Any" => 0, "Text::LineFold" => 0, "overload" => 0, "parent" => 0, "perl" => "5.006", "strict" => 0, "warnings" => 0 }, "script_files" => [], "share_dir" => { "dist" => "share" }, "test_requires" => { "Capture::Tiny" => 0, "English" => 0, "File::Spec" => 0, "FindBin" => 0, "IO::Handle" => 0, "IPC::Open3" => 0, "Import::Into" => 0, "Moo" => "1.003001", "POSIX" => 0, "Role::Tiny::With" => 0, "Test::More" => "0.94", "Test::Requires" => 0, "Test::Trap" => 0, "Try::Tiny" => 0, "lib" => 0, "namespace::clean" => 0, "perl" => "5.006" } ); my %fallback_build_requires = ( "Capture::Tiny" => 0, "English" => 0, "File::Spec" => 0, "FindBin" => 0, "IO::Handle" => 0, "IPC::Open3" => 0, "Import::Into" => 0, "Module::Build" => "0.4211", "Moo" => "1.003001", "POSIX" => 0, "Role::Tiny::With" => 0, "Test::More" => "0.94", "Test::Requires" => 0, "Test::Trap" => 0, "Try::Tiny" => 0, "lib" => 0, "namespace::clean" => 0, "perl" => "5.006" ); unless ( eval { Module::Build->VERSION(0.4004) } ) { delete $module_build_args{test_requires}; $module_build_args{build_requires} = \%fallback_build_requires; } my $build = Module::Build->new(%module_build_args); $build->create_build_script; base.st100644001751001751 4110312741266240 14407 0ustar00devdev000000000000MooX-Options-4.023/tlocal $ENV{TEST_FORCE_COLUMN_SIZE} = 78; my @params = qw/bool counter empty/; subtest "no args" => sub { note "no args"; local @ARGV = (); my $t = t->new_with_options(); ok( $t->can($_), "$_ defined" ) for @params; is( $t->$_, undef, "$_ values is undef" ) for @params; is( $t->has_default, 'foo', 'Default works correctly' ); done_testing(); }; subtest "args value" => sub { note "args value with repeatable"; local @ARGV = ( '--bool', '--counter', '--counter', '--counter', '--empty' ); my $t = t->new_with_options(); note "bool ", $t->bool; note "counter ", $t->counter; note "empty ", $t->empty; ok( $t->$_, "$_ values is defined" ) for @params; is( $t->bool, 1, "bool is well defined" ); is( $t->counter, 3, "counter is well defined" ); is( $t->empty, 1, "empty is well defined" ); done_testing(); }; subtest "negativable" => sub { note "negativable"; local @ARGV = ( '--empty', '--no-empty' ); my $t = t->new_with_options(); is( $t->empty, 0, "empty is well defined" ); done_testing(); }; subtest "split" => sub { note "split"; { local @ARGV = ('--split=1'); my $t = t->new_with_options(); is_deeply( $t->split, [1], "split one arg" ); } { local @ARGV = ( '--split=1', '--split=2' ); my $t = t->new_with_options(); is_deeply( $t->split, [ 1, 2 ], "split two arg" ); } { local @ARGV = ('--split=1,2'); my $t = t->new_with_options(); is_deeply( $t->split, [ 1, 2 ], "split one arg autosplit" ); } { local @ARGV = ( '--split=1', '--split=2', '--split=3,4' ); my $t = t->new_with_options(); is_deeply( $t->split, [ 1, 2, 3, 4 ], "split three arg with autosplit" ); } { local @ARGV = ( '--split', '1', '--split', '2', '--split', '3,4' ); my $t = t->new_with_options(); is_deeply( $t->split, [ 1, 2, 3, 4 ], "split three arg with autosplit and space" ); } done_testing(); }; subtest "test required" => sub { note "test required"; { local @ARGV = (); my @r = trap { r->new_with_options }; is( $trap->exit, 1, "missing args, exit 1" ); like( $trap->stderr, qr/^str_req is missing/, "str_reg is missing" ); } { local @ARGV = ('--str_req=ok'); my $t = r->new_with_options; is( $t->str_req, 'ok', 'str req is ok' ); } { local @ARGV = (); my @r = trap { multi_req->new_with_options }; is( $trap->exit, 1, "missing args exit 1" ); my @missing = $trap->stderr =~ /(multi_\d is missing)\n/g; my @target_isa; { no strict 'refs'; @target_isa = @{"multi_req::ISA"} }; if ( multi_req->isa('Moose::Object') || multi_req->isa('Mo::Object') ) { is( scalar @missing, 1, "only one missing for moose" ); } else { is( scalar @missing, 3, "multi is missing" ); } } done_testing(); }; subtest "test help" => sub { note "test help"; { local @ARGV = ('--help'); my @r = trap { r->new_with_options }; is( $trap->exit, 0, "help, exit 0" ); ok( $trap->stdout !~ /^str_req is missing/, "str_reg is missing" ); } done_testing(); }; subtest "test short help" => sub { note "test short help"; { local @ARGV = ('--usage'); my @r = trap { r->new_with_options }; is( $trap->exit, 0, "help, exit 0" ); ok( $trap->stdout !~ /^str_req is missing/, "str_reg is missing" ); like $trap->stdout, qr{\QUSAGE: m\E\w+\Q.t [ --str_req=String ] | [ --usage ] [ -h ] [ --help ] [ --man ]\E}, 'usage message ok'; } done_testing(); }; subtest "value override" => sub { note "value override"; { local @ARGV = (); my $t = r->new_with_options( str_req => "ok" ); is( $t->str_req, 'ok', 'str req is ok' ); } { local @ARGV = ('--str_req=ko'); my $t = r->new_with_options( str_req => "ok" ); is( $t->str_req, 'ok', 'str req is override with ok' ); } done_testing(); }; subtest "split_complexe_str" => sub { note "split on complexe str"; { local @ARGV = ("--split_str=a,b,c"); my $t = sp_str->new_with_options(); is_deeply( $t->split_str, [qw/a b c/], 'str req is ok' ); } { local @ARGV = ("--split-str=a,b,c"); my $t = sp_str->new_with_options(); is_deeply( $t->split_str, [qw/a b c/], 'str req is ok' ); } { local @ARGV = ("--split_conflict_str1=a,b,c"); my $t = sp_str->new_with_options(); is_deeply( $t->split_conflict_str1, [qw/a b c/], 'str req is ok' ); } { local @ARGV = ("--split_conflict-str1=a,b,c"); my $t = sp_str->new_with_options(); is_deeply( $t->split_conflict_str1, [qw/a b c/], 'str req is ok' ); } { local @ARGV = ("--split-conflict_str1=a,b,c"); my $t = sp_str->new_with_options(); is_deeply( $t->split_conflict_str1, [qw/a b c/], 'str req is ok' ); } { local @ARGV = ("--split-conflict-str1=a,b,c"); my $t = sp_str->new_with_options(); is_deeply( $t->split_conflict_str1, [qw/a b c/], 'str req is ok' ); } { local @ARGV = ('--split_str=a,"b,c",d'); my $t = sp_str->new_with_options(); is_deeply( $t->split_str, [ 'a', 'b,c', 'd' ], 'str req is ok' ); } { local @ARGV = ('--split-str=a,"b,c",d'); my $t = sp_str->new_with_options(); is_deeply( $t->split_str, [ 'a', 'b,c', 'd' ], 'str req is ok' ); } done_testing(); }; subtest "split_complexe_str_short" => sub { note "split on complexe str short"; { local @ARGV = ("-z=a"); my $t = sp_str_short->new_with_options(); is_deeply( $t->split_str, [qw/a/], 'str req is ok' ); } { local @ARGV = ("-z=a,b,c"); my $t = sp_str_short->new_with_options(); is_deeply( $t->split_str, [qw/a b c/], 'str req is ok' ); } { local @ARGV = ('-z=a,"b,c",d'); my $t = sp_str_short->new_with_options(); is_deeply( $t->split_str, [ 'a', 'b,c', 'd' ], 'str req is ok' ); } { local @ARGV = ( '-z', 'a,"b,c",d' ); my $t = sp_str_short->new_with_options(); is_deeply( $t->split_str, [ 'a', 'b,c', 'd' ], 'str req is ok' ); } done_testing(); }; subtest "split_str_shorter_name" => sub { note "shorter long split"; { local @ARGV = ("--split_st=a,b,c"); my $t = sp_str->new_with_options(); is_deeply( $t->split_str, [qw/a b c/], 'str req is ok' ); } { local @ARGV = ("--split-st=a,b,c"); my $t = sp_str->new_with_options(); is_deeply( $t->split_str, [qw/a b c/], 'str req is ok' ); } note "shorter long split with conflict"; { local @ARGV = ("--split_co=a,b,c"); trap { sp_str->new_with_options(); }; like $trap->stderr, qr/Option\ssplit_co\sis\sambiguous/, 'conflict detected'; local @ARGV = ("--split-co=a,b,c"); trap { sp_str->new_with_options(); }; like $trap->stderr, qr/Option\ssplit_co\sis\sambiguous/, 'conflict detected'; } done_testing(); }; subtest "should_die_ok" => sub { note "Test chain method"; trap { d->new_with_options( should_die_ok => 1 ) }; like( $trap->stderr, qr/this\s\will\sdie\sok/, 'should die ok' ); }; subtest "test usage" => sub { note "test usage method"; my $s = sp_str->new_with_options(); my @r = trap { $s->options_usage( 127, 'usage work', 'usage really work' ) }; is( $trap->exit, 127, 'exit code is correct' ); like( $trap->stderr, qr/usage work/, 'custom message is present' ); like( $trap->stderr, qr/usage really work/, 'custom message is really present' ); like( $trap->stderr, qr/help\s+show a long help message/, 'help is present' ); like( $trap->stderr, qr/split_str=\[Strings\]\s+no doc for split_str/, 'attr no doc is present' ); }; subtest "test short usage" => sub { note "test usage method"; my $s = sp_str->new_with_options(); my @r = trap { $s->options_short_usage(127) }; is( $trap->exit, 127, 'exit code is correct' ); like $trap->stderr, qr{\QUSAGE: m\E\w+\Q.t [ --split_conflict_str1=[Strings] ] [ --split_conflict_str2=[Strings] ] [ --split_str=[Strings] ] | [ --usage ] [ -h ] [ --help ] [ --man ]\E}, 'short message ok'; }; subtest "doc usage" => sub { note "doc usage"; my $s = t_doc->new_with_options(); my @r = trap { $s->options_usage(127) }; is( $trap->exit, 127, 'exit code is correct' ); like( $trap->stderr, qr/t\s+this is a test/, 'doc on attribute' ); }; subtest "test short" => sub { note "test short"; my $s = t_short->new_with_options(); trap { $s->options_usage }; like( $trap->stdout, qr/\-v \-\-verbose/, 'short doc ok' ); }; subtest "test skip_options" => sub { note "test skip_options"; my $s = t_skipopt->new_with_options(); trap { $s->options_usage() }; ok( $trap->stdout !~ /\-\-multi/, 'multi is no more an option' ); }; subtest "test prefer_commandline" => sub { note "test prefer_commandline"; { local @ARGV = ('--t=override'); my $t = t_prefer_cli->new_with_options( t => 'default value' ); is( $t->t, 'override', 'prefer_commandline ok' ); } }; subtest "test dash" => sub { note "test dash"; { local @ARGV = ('--start_date=2012-12-12'); my $t = t_dash->new_with_options(); is( $t->start_date, '2012-12-12', '--start_date ok' ); } { local @ARGV = ('--start-date=2012-12-12'); my $t = t_dash->new_with_options(); is( $t->start_date, '2012-12-12', '--start-date ok' ); } { local @ARGV = ('-s2012-12-12'); my $t = t_dash->new_with_options(); is( $t->start_date, '2012-12-12', '-s ok' ); } }; subtest "json" => sub { note "json"; { local @ARGV = ( "--t", "{\"a\":1,\"b\":2}" ); my $t = t_json->new_with_options(); is_deeply( $t->t, { a => 1, b => 2 }, 'json properly set' ); } { local @ARGV = ( "--t", "bad json" ); my $t = trap { t_json->new_with_options }; like( $trap->stderr, qr/malformed JSON string/, "decode json failed" ); like( $trap->stderr, qr/\-t=JSON/, "json help message properly set" ); } { local @ARGV = ('--help'); my $t = trap { t_json->new_with_options }; note $trap->stdout; like( $trap->stdout, qr/\-t:\sJSON/, "json help message properly set" ); } { trap { t_json->new->options_man( undef, *STDOUT ); }; like( $trap->stdout, qr/\-t: JSON/, "json man message properly set" ) or diag $trap->stdout; } }; subtest "json format" => sub { note "json format"; { local @ARGV = ( "--t", "{\"a\":1,\"b\":2}" ); my $t = t_json_opt->new_with_options(); is_deeply( $t->t, { a => 1, b => 2 }, 'json properly set' ); } { local @ARGV = ( "--t", "bad json" ); my $t = trap { t_json_opt->new_with_options }; ok( $trap->stderr =~ /malformed JSON string/, "decode json failed" ); ok( $trap->stderr =~ /\-t=JSON/, "json help message properly set" ); } { local @ARGV = ('--help'); my $t = trap { t_json_opt->new_with_options }; ok( $trap->stdout =~ /\-t: JSON/, "json help message properly set" ); } { trap { t_json_opt->new->options_man( undef, *STDOUT ); }; ok( $trap->stdout =~ /\-t: JSON/, "json help message properly set" ) or diag $trap->stdout; } }; subtest "range_complexe_str" => sub { note "range on complexe str"; { local @ARGV = ('--range_str=1,2,4'); my $t = rg_str->new_with_options(); is_deeply( $t->range_str, [qw/1 2 4/], 'str1 req is ok' ); } { local @ARGV = ('--range-str=1,2,4..'); my $t = rg_str->new_with_options(); is_deeply( $t->range_str, [qw/1 2 4/], 'str2 req is ok' ); } { local @ARGV = ('--range_str=1,2,4..6'); my $t = rg_str->new_with_options(); is_deeply( $t->range_str, [qw/1 2 4 5 6/], 'str3 req is ok' ); } { local @ARGV = ('--range-str=1,2,4..6'); my $t = rg_str->new_with_options(); is_deeply( $t->range_str, [qw/1 2 4 5 6/], 'str4 req is ok' ); } { local @ARGV = ('--range_str=1,2,4..'); my $t = rg_str->new_with_options(); is_deeply( $t->range_str, [qw/1 2 4/], 'str req5 is ok' ); } { local @ARGV = ('--range-str=1,2,4..'); my $t = rg_str->new_with_options(); is_deeply( $t->range_str, [qw/1 2 4/], 'str req6 is ok' ); } { local @ARGV = ("--range_str=1,2,4..7,10"); my $t = rg_str->new_with_options(); is_deeply( $t->range_str, [qw/1 2 4 5 6 7 10/], 'str7 req is ok' ); } { local @ARGV = ("--range-str=1,2,4..7,10"); my $t = rg_str->new_with_options(); is_deeply( $t->range_str, [qw/1 2 4 5 6 7 10/], 'str8 req is ok' ); } { local @ARGV = ('--range_str=1..3,10..12,20..'); my $t = rg_str->new_with_options(); is_deeply( $t->range_str, [qw/1 2 3 10 11 12 20/], 'str9 req is ok' ); } { local @ARGV = ('--range-str=1..3,10..12,20..'); my $t = rg_str->new_with_options(); is_deeply( $t->range_str, [qw/1 2 3 10 11 12 20/], 'str10 req is ok' ); } { local @ARGV = ('--range_str=1,"2,3",4,"foo bar"'); my $t = rg_str->new_with_options(); is_deeply( $t->range_str, [ 1, "2,3", 4, "foo bar" ], 'str11 req is ok' ); } { local @ARGV = ('--range-str=1,"2,3",4,"a,2,c"'); my $t = rg_str->new_with_options(); is_deeply( $t->range_str, [ 1, "2,3", 4, "a,2,c" ], 'str12 req is ok' ); } done_testing(); }; subtest "range_complexe_str_short" => sub { note "range on complexe str short"; { local @ARGV = ("-r=1"); my $t = rg_str_short->new_with_options(); is_deeply( $t->range_str, [qw/1/], 'str1 req is ok' ); } { local @ARGV = ("-r=1,2,4"); my $t = rg_str_short->new_with_options(); is_deeply( $t->range_str, [qw/1 2 4/], 'str2 req is ok' ); } { local @ARGV = ("-r=1..4"); my $t = rg_str_short->new_with_options(); is_deeply( $t->range_str, [qw/1 2 3 4/], 'str3 req is ok' ); } { local @ARGV = ( '-r', "1..4" ); my $t = rg_str_short->new_with_options(); is_deeply( $t->range_str, [qw/1 2 3 4/], 'str4 req is ok' ); } { local @ARGV = ("-r=1,2,4..7,10"); my $t = rg_str_short->new_with_options(); is_deeply( $t->range_str, [qw/1 2 4 5 6 7 10/], 'str5 req is ok' ); } { local @ARGV = ( '-r', '1..3,10..12,20..' ); my $t = rg_str_short->new_with_options(); is_deeply( $t->range_str, [qw/1 2 3 10 11 12 20/], 'str6 req is ok' ); } { local @ARGV = ('-r=1,"2,3",4'); my $t = rg_str_short->new_with_options(); is_deeply( $t->range_str, [ '1', "2,3", '4' ], 'str7 req is ok' ); } { local @ARGV = ( '-r', '1,"2,3",4..7' ); my $t = rg_str_short->new_with_options(); is_deeply( $t->range_str, [ 1, "2,3", 4, 5, 6, 7 ], 'str8 req is ok' ); } done_testing(); }; subtest "range_str_shorter_name" => sub { note "shorter long range"; { local @ARGV = ("--range_st=1,2,4..6"); my $t = rg_str->new_with_options(); is_deeply( $t->range_str, [qw/1 2 4 5 6/], 'str1 req is ok' ); } { local @ARGV = ("--range-st=1,2,4..6,7"); my $t = rg_str->new_with_options(); is_deeply( $t->range_str, [qw/1 2 4 5 6 7/], 'str2 req is ok' ); } note "shorter long range with conflict"; { local @ARGV = ("--range_co=1,2,3"); trap { rg_str->new_with_options(); }; like $trap->stderr, qr/Option\srange_co\sis\sambiguous/, 'conflict detected'; local @ARGV = ("--range-co=1,2,3"); trap { rg_str->new_with_options(); }; like $trap->stderr, qr/Option\srange_co\sis\sambiguous/, 'conflict detected'; } done_testing(); }; 1; order.t100644001751001751 467712741266240 14424 0ustar00devdev000000000000MooX-Options-4.023/t#!perl # # This file is part of MooX-Options # # This software is copyright (c) 2013 by celogeek . # # This is free software; you can redistribute it and/or modify it under # the same terms as the Perl 5 programming language system itself. # use t::Test; use Test::Trap; local $ENV{TEST_FORCE_COLUMN_SIZE} = 78; { package t1; use Moo; use MooX::Options; option 'first' => ( is => 'ro', documentation => 'first option', order => 1, ); option 'second' => ( is => 'ro', documentation => 'second option', order => 2, ); option 'third' => ( is => 'ro', documentation => 'third option', order => 3, ); option 'fourth' => ( is => 'ro', documentation => 'fourth option', order => 4, ); 1; } { package t2; use Moo; use MooX::Options; option 'first' => ( is => 'ro', documentation => 'first option', ); option 'second' => ( is => 'ro', documentation => 'second option', ); option 'third' => ( is => 'ro', documentation => 'third option', ); option 'fourth' => ( is => 'ro', documentation => 'fourth option', ); 1; } { package t3; use Moo; use MooX::Options; option 'first' => ( is => 'ro', documentation => 'first option', order => 1, ); option 'second' => ( is => 'ro', documentation => 'second option', order => 2, ); option 'third' => ( is => 'ro', documentation => 'third option', ); option 'fourth' => ( is => 'ro', documentation => 'fourth option', ); 1; } { my $opt = t1->new_with_options; trap { $opt->options_usage }; like $trap->stdout, qr/first.+second.+third.+fourth/ms, 'order work w/ order attribute'; } { my $opt = t2->new_with_options; trap { $opt->options_usage }; like $trap->stdout, qr/first.+fourth.+second.+third/ms, 'order work w/o order attribute'; } { my $opt = t3->new_with_options; trap { $opt->options_usage }; like $trap->stdout, qr/fourth.+third.+first.+second/ms, 'order work w/ mixed mode'; } done_testing; Test.pm100644001751001751 107312741266240 14364 0ustar00devdev000000000000MooX-Options-4.023/t# # This file is part of MooX-Options # # This software is copyright (c) 2013 by celogeek . # # This is free software; you can redistribute it and/or modify it under # the same terms as the Perl 5 programming language system itself. # package t::Test; use strict; use warnings; use Test::More; use Import::Into; use POSIX qw/setlocale LC_ALL/; sub import { $ENV{LC_ALL} = 'C'; setlocale( LC_ALL, 'C' ); my $target = caller; strict->import::into($target); warnings->import::into($target); Test::More->import::into($target); } 1; moose.t100644001751001751 665512741266240 14431 0ustar00devdev000000000000MooX-Options-4.023/t#!/usr/bin/env perl # # This file is part of MooX-Options # # This software is copyright (c) 2013 by celogeek . # # This is free software; you can redistribute it and/or modify it under # the same terms as the Perl 5 programming language system itself. # use t::Test; use Test::Trap; use Carp; use FindBin qw/$RealBin/; use Try::Tiny; BEGIN { eval 'use Moose'; if ($@) { plan skip_all => 'Need Moose for this test'; exit 0; } } { package t; use Moose; use MooX::Options; option 'bool' => ( is => 'ro' ); option 'counter' => ( is => 'ro', repeatable => 1 ); option 'empty' => ( is => 'ro', negativable => 1 ); option 'split' => ( is => 'ro', format => 'i@', autosplit => ',' ); option 'has_default' => ( is => 'ro', default => sub {'foo'} ); option 'range' => ( is => 'ro', format => 'i@', autorange => 1 ); 1; } { package r; use Moose; use MooX::Options; option 'str_req' => ( is => 'ro', format => 's', required => 1 ); 1; } { package sp_str; use Moose; use MooX::Options; option 'split_str' => ( is => 'ro', format => 's', autosplit => "," ); option 'split_conflict_str1' => ( is => 'ro', format => 's', autosplit => "," ); option 'split_conflict_str2' => ( is => 'ro', format => 's', autosplit => "," ); 1; } { package sp_str_short; use Moose; use MooX::Options; option 'split_str' => ( is => 'ro', format => 's', autosplit => ",", short => 'z' ); 1; } { package d; use Moose; use MooX::Options; option 'should_die_ok' => ( is => 'ro', trigger => sub { die "this will die ok" } ); 1; } { package multi_req; use Moose; use MooX::Options; option 'multi_1' => ( is => 'ro', required => 1 ); option 'multi_2' => ( is => 'ro', required => 1 ); option 'multi_3' => ( is => 'ro', required => 1 ); 1; } { package t_doc; use Moose; use MooX::Options; option 't' => ( is => 'ro', doc => 'this is a test' ); 1; } { package t_short; use Moose; use MooX::Options; option 'verbose' => ( is => 'ro', short => 'v' ); 1; } { package t_skipopt; use Moose; use MooX::Options skip_options => [qw/multi/]; option 'multi' => ( is => 'ro' ); 1; } { package t_prefer_cli; use Moose; use MooX::Options prefer_commandline => 1; option 't' => ( is => 'ro', format => 's' ); 1; } { package t_dash; use Moose; use MooX::Options; option 'start_date' => ( is => 'ro', format => 's', short => 's' ); 1; } { package t_json; use Moose; use MooX::Options; option 't' => ( is => 'ro', json => 1 ); 1; } { package t_json_opt; use Moose; use MooX::Options; option 't' => ( is => 'ro', format => 'json' ); 1; } { package rg_str; use Moose; use MooX::Options; option 'range_str' => ( is => 'ro', format => 's', autorange => 1 ); option 'range_conflict_str1' => ( is => 'ro', format => 's', autorange => 1 ); option 'range_conflict_str2' => ( is => 'ro', format => 's', autorange => 1 ); 1; } { package rg_str_short; use Moose; use MooX::Options; option 'range_str' => ( is => 'ro', format => 's', autorange => 1, short => 'r' ); 1; } subtest "Moose" => sub { note "Test Moose"; require $RealBin . '/base.st'; }; done_testing; META.json100644001751001751 3434612741266240 14316 0ustar00devdev000000000000MooX-Options-4.023{ "abstract" : "Explicit Options eXtension for Object Class", "author" : [ "celogeek " ], "dynamic_config" : 0, "generated_by" : "Dist::Zilla version 5.036, CPAN::Meta::Converter version 2.150001", "license" : [ "perl_5" ], "meta-spec" : { "url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec", "version" : 2 }, "name" : "MooX-Options", "prereqs" : { "build" : { "requires" : { "Module::Build" : "0.4211" } }, "configure" : { "requires" : { "Module::Build" : "0.4211", "perl" : "5.006" } }, "develop" : { "requires" : { "Pod::Coverage::TrustPod" : "0", "Test::Pod::Coverage" : "1.08" } }, "runtime" : { "recommends" : { "Term::Size::Any" : "0" }, "requires" : { "Carp" : "0", "Data::Record" : "0", "Getopt::Long" : "2.43", "Getopt::Long::Descriptive" : "0.099", "JSON::MaybeXS" : "0", "Locale::TextDomain" : "0", "Module::Metadata" : "1.000019", "Moo" : "1.003001", "MooX::ConfigFromFile" : "0", "Path::Class" : "0.32", "Pod::Usage" : "0", "Regexp::Common" : "0", "Scalar::Util" : "0", "Term::Size::Any" : "0", "Text::LineFold" : "0", "overload" : "0", "parent" : "0", "perl" : "5.006", "strict" : "0", "warnings" : "0" } }, "test" : { "requires" : { "Capture::Tiny" : "0", "English" : "0", "File::Spec" : "0", "FindBin" : "0", "IO::Handle" : "0", "IPC::Open3" : "0", "Import::Into" : "0", "Moo" : "1.003001", "POSIX" : "0", "Role::Tiny::With" : "0", "Test::More" : "0.94", "Test::Requires" : "0", "Test::Trap" : "0", "Try::Tiny" : "0", "lib" : "0", "namespace::clean" : "0", "perl" : "5.006" } } }, "release_status" : "stable", "resources" : { "bugtracker" : { "web" : "https://github.com/celogeek/MooX-Options/issues" }, "homepage" : "https://tasks.celogeek.com/projects/perl-modules-moox-options", "repository" : { "type" : "git", "url" : "https://github.com/celogeek/MooX-Options.git", "web" : "https://github.com/celogeek/MooX-Options" } }, "version" : "4.023", "x_Dist_Zilla" : { "perl" : { "version" : "5.020003" }, "plugins" : [ { "class" : "Dist::Zilla::Plugin::GatherDir", "config" : { "Dist::Zilla::Plugin::GatherDir" : { "exclude_filename" : [], "exclude_match" : [], "follow_symlinks" : "0", "include_dotfiles" : "0", "prefix" : "", "prune_directory" : [], "root" : "." } }, "name" : "@GRS/@Filter/GatherDir", "version" : "5.036" }, { "class" : "Dist::Zilla::Plugin::PruneCruft", "name" : "@GRS/@Filter/PruneCruft", "version" : "5.036" }, { "class" : "Dist::Zilla::Plugin::ManifestSkip", "name" : "@GRS/@Filter/ManifestSkip", "version" : "5.036" }, { "class" : "Dist::Zilla::Plugin::MetaYAML", "name" : "@GRS/@Filter/MetaYAML", "version" : "5.036" }, { "class" : "Dist::Zilla::Plugin::License", "name" : "@GRS/@Filter/License", "version" : "5.036" }, { "class" : "Dist::Zilla::Plugin::Readme", "name" : "@GRS/@Filter/Readme", "version" : "5.036" }, { "class" : "Dist::Zilla::Plugin::ExtraTests", "name" : "@GRS/@Filter/ExtraTests", "version" : "5.036" }, { "class" : "Dist::Zilla::Plugin::ExecDir", "name" : "@GRS/@Filter/ExecDir", "version" : "5.036" }, { "class" : "Dist::Zilla::Plugin::ShareDir", "name" : "@GRS/@Filter/ShareDir", "version" : "5.036" }, { "class" : "Dist::Zilla::Plugin::Manifest", "name" : "@GRS/@Filter/Manifest", "version" : "5.036" }, { "class" : "Dist::Zilla::Plugin::TestRelease", "name" : "@GRS/@Filter/TestRelease", "version" : "5.036" }, { "class" : "Dist::Zilla::Plugin::ConfirmRelease", "name" : "@GRS/@Filter/ConfirmRelease", "version" : "5.036" }, { "class" : "Dist::Zilla::Plugin::ReportVersions", "name" : "@GRS/ReportVersions", "version" : "1.110730" }, { "class" : "Dist::Zilla::Plugin::OurPkgVersion", "name" : "@GRS/OurPkgVersion", "version" : "0.06" }, { "class" : "Dist::Zilla::Plugin::Prepender", "name" : "@GRS/Prepender", "version" : "2.001" }, { "class" : "Dist::Zilla::Plugin::MinimumPerl", "name" : "@GRS/MinimumPerl", "version" : "1.006" }, { "class" : "Dist::Zilla::Plugin::Test::Compile", "config" : { "Dist::Zilla::Plugin::Test::Compile" : { "bail_out_on_fail" : "0", "fail_on_warning" : "author", "fake_home" : "0", "filename" : "t/00-compile.t", "module_finder" : [ ":InstallModules" ], "needs_display" : "0", "phase" : "test", "script_finder" : [ ":ExecFiles" ], "skips" : [] } }, "name" : "@GRS/Test::Compile", "version" : "2.053" }, { "class" : "Dist::Zilla::Plugin::Test::UnusedVars", "name" : "@GRS/Test::UnusedVars", "version" : "2.000007" }, { "class" : "Dist::Zilla::Plugin::PodCoverageTests", "name" : "@GRS/PodCoverageTests", "version" : "5.036" }, { "class" : "Dist::Zilla::Plugin::PruneFiles", "name" : "@GRS/PruneFiles", "version" : "5.036" }, { "class" : "Dist::Zilla::Plugin::ReadmeMarkdownFromPod", "name" : "@GRS/ReadmeMarkdownFromPod", "version" : "0.141140" }, { "class" : "Dist::Zilla::Plugin::MetaJSON", "name" : "@GRS/MetaJSON", "version" : "5.036" }, { "class" : "Dist::Zilla::Plugin::MetaConfig", "name" : "@GRS/MetaConfig", "version" : "5.036" }, { "class" : "Dist::Zilla::Plugin::PodWeaver", "config" : { "Dist::Zilla::Plugin::PodWeaver" : { "config_plugins" : [ "@GRS" ], "finder" : [ ":InstallModules", ":ExecFiles" ], "plugins" : [ { "class" : "Pod::Weaver::Plugin::EnsurePod5", "name" : "@CorePrep/EnsurePod5", "version" : "4.012" }, { "class" : "Pod::Weaver::Plugin::H1Nester", "name" : "@CorePrep/H1Nester", "version" : "4.012" }, { "class" : "Pod::Weaver::Section::Name", "name" : "@Default/Name", "version" : "4.012" }, { "class" : "Pod::Weaver::Section::Version", "name" : "@Default/Version", "version" : "4.012" }, { "class" : "Pod::Weaver::Section::Region", "name" : "@Default/prelude", "version" : "4.012" }, { "class" : "Pod::Weaver::Section::Generic", "name" : "DESCRIPTION", "version" : "4.012" }, { "class" : "Pod::Weaver::Section::Generic", "name" : "SYNOPSIS", "version" : "4.012" }, { "class" : "Pod::Weaver::Section::Generic", "name" : "OVERVIEW", "version" : "4.012" }, { "class" : "Pod::Weaver::Section::Collect", "name" : "ATTRIBUTES", "version" : "4.012" }, { "class" : "Pod::Weaver::Section::Collect", "name" : "METHODS", "version" : "4.012" }, { "class" : "Pod::Weaver::Section::Collect", "name" : "FUNCTIONS", "version" : "4.012" }, { "class" : "Pod::Weaver::Section::Leftovers", "name" : "@Default/Leftovers", "version" : "4.012" }, { "class" : "Pod::Weaver::Section::Region", "name" : "@Default/postlude", "version" : "4.012" }, { "class" : "Pod::Weaver::Section::Bugs", "name" : "@Default/Bugs", "version" : "4.012" }, { "class" : "Pod::Weaver::Section::Authors", "name" : "@Default/Authors", "version" : "4.012" }, { "class" : "Pod::Weaver::Section::Legal", "name" : "@Default/Legal", "version" : "4.012" } ] } }, "name" : "@GRS/PodWeaver", "version" : "4.006" }, { "class" : "Dist::Zilla::Plugin::PerlTidy", "name" : "@GRS/PerlTidy", "version" : "0.21" }, { "class" : "Dist::Zilla::Plugin::Test::Perl::Critic", "name" : "@GRS/Test::Perl::Critic", "version" : "3.000" }, { "class" : "Dist::Zilla::Plugin::Test::Kwalitee::Extra", "name" : "@GRS/Test::Kwalitee::Extra", "version" : "v0.2.1" }, { "class" : "Dist::Zilla::Plugin::ModuleBuild", "config" : { "Dist::Zilla::Role::TestRunner" : { "default_jobs" : 1 } }, "name" : "ModuleBuild", "version" : "5.036" }, { "class" : "Dist::Zilla::Plugin::AutoPrereqs", "name" : "AutoPrereqs", "version" : "5.036" }, { "class" : "Dist::Zilla::Plugin::Prereqs", "config" : { "Dist::Zilla::Plugin::Prereqs" : { "phase" : "runtime", "type" : "requires" } }, "name" : "Prereqs", "version" : "5.036" }, { "class" : "Dist::Zilla::Plugin::Prereqs", "config" : { "Dist::Zilla::Plugin::Prereqs" : { "phase" : "runtime", "type" : "recommends" } }, "name" : "RuntimeRecommends", "version" : "5.036" }, { "class" : "Dist::Zilla::Plugin::MetaResourcesFromGit", "name" : "MetaResourcesFromGit", "version" : "1.103620" }, { "class" : "Dist::Zilla::Plugin::LocaleTextDomain", "name" : "LocaleTextDomain", "version" : "0.90" }, { "class" : "Dist::Zilla::Plugin::FinderCode", "name" : ":InstallModules", "version" : "5.036" }, { "class" : "Dist::Zilla::Plugin::FinderCode", "name" : ":IncModules", "version" : "5.036" }, { "class" : "Dist::Zilla::Plugin::FinderCode", "name" : ":TestFiles", "version" : "5.036" }, { "class" : "Dist::Zilla::Plugin::FinderCode", "name" : ":ExecFiles", "version" : "5.036" }, { "class" : "Dist::Zilla::Plugin::FinderCode", "name" : ":ShareFiles", "version" : "5.036" }, { "class" : "Dist::Zilla::Plugin::FinderCode", "name" : ":MainModule", "version" : "5.036" }, { "class" : "Dist::Zilla::Plugin::FinderCode", "name" : ":AllFiles", "version" : "5.036" }, { "class" : "Dist::Zilla::Plugin::FinderCode", "name" : ":NoFiles", "version" : "5.036" } ], "zilla" : { "class" : "Dist::Zilla::Dist::Builder", "config" : { "is_trial" : "0" }, "version" : "5.036" } } } hidden.t100644001751001751 216212741266240 14527 0ustar00devdev000000000000MooX-Options-4.023/t#!perl # # This file is part of MooX-Options # # This software is copyright (c) 2013 by celogeek . # # This is free software; you can redistribute it and/or modify it under # the same terms as the Perl 5 programming language system itself. # use t::Test; use Test::Trap; { package t; use Moo; use MooX::Options; option 'visible_option' => ( is => 'ro', doc => 'visible' ); option 'hidden_option_by_doc' => ( is => 'ro', format => 's', doc => 'hidden' ); option 'hidden_option' => ( is => 'ro', format => 's', hidden => 1, doc => 'not visible' ); 1; } trap { local @ARGV = qw(--help); t->new_with_options }; unlike $trap->stdout, qr/hidden_option_by_doc:/, 'hidden by doc'; unlike $trap->stdout, qr/hidden_option:/, 'hidden by option'; like $trap->stdout, qr/visible_option:/, 'visible option'; { local @ARGV = qw(--hidden_option_by_doc=test1 --hidden_option=test2); my $o = t->new_with_options; is $o->hidden_option_by_doc, 'test1', 'hidden by doc exists'; is $o->hidden_option, 'test2', 'hidden by option exists'; } done_testing; spacer.t100644001751001751 235412741266240 14554 0ustar00devdev000000000000MooX-Options-4.023/t#!perl # # This file is part of MooX-Options # # This software is copyright (c) 2013 by celogeek . # # This is free software; you can redistribute it and/or modify it under # the same terms as the Perl 5 programming language system itself. # use t::Test; use Test::Trap; use Carp; use FindBin qw/$RealBin/; use Try::Tiny; local $ENV{TEST_FORCE_COLUMN_SIZE} = 78; { package t; use Moo; use MooX::Options spacer => '+'; option 'a' => ( is => 'ro' ); option 'b' => ( is => 'ro', spacer_before => 1, spacer_after => 1 ); option 'c' => ( is => 'ro' ); 1; } my $opt = t->new_with_options; my @usages; trap { $opt->options_usage }; @usages = grep {/\-[abc]\s+|\+/} split( /\n/, $trap->stdout ); like $usages[0], qr/a/, 'a is first'; like $usages[1], qr/\++/, 'then the spacer'; like $usages[2], qr/b/, 'b is next'; like $usages[3], qr/\++/, 'then the spacer'; like $usages[4], qr/c/, 'c is last'; trap { $opt->options_help }; @usages = grep {/[abc]:|\+/} split( /\n/, $trap->stdout ); like $usages[0], qr/a:/, 'a is first'; like $usages[1], qr/\++/, 'then the spacer'; like $usages[2], qr/b:/, 'b is next'; like $usages[3], qr/\++/, 'then the spacer'; like $usages[4], qr/c:/, 'c is last'; done_testing; README.mkdn100644001751001751 2752512741266240 14506 0ustar00devdev000000000000MooX-Options-4.023# NAME MooX::Options - Explicit Options eXtension for Object Class # VERSION version 4.023 # DESCRIPTION Create a command line tool with your [Mo](https://metacpan.org/pod/Mo), [Moo](https://metacpan.org/pod/Moo), [Moose](https://metacpan.org/pod/Moose) objects. Everything is explicit. You have an `option` keyword to replace the usual `has` to explicitly use your attribute into the command line. The `option` keyword takes additional parameters and uses [Getopt::Long::Descriptive](https://metacpan.org/pod/Getopt::Long::Descriptive) to generate a command line tool. # SYNOPSIS In myOptions.pm : package myOptions; use Moo; use MooX::Options; option 'show_this_file' => ( is => 'ro', format => 's', required => 1, doc => 'the file to display' ); 1; In myTool.pl : use myOptions; use Path::Class; my $opt = myOptions->new_with_options; print "Content of the file : ", file($opt->show_this_file)->slurp; To use it : perl myTool.pl --show_this_file=myFile.txt Content of the file: myFile content The help message : perl myTool.pl --help USAGE: myTool.pl [-h] [long options...] --show_this_file: String the file to display -h --help: show this help message --man: show the manual The usage message : perl myTool.pl --usage USAGE: myTool.pl [ --show_this_file=String ] [ --usage ] [ --help ] [ --man ] The manual : perl myTool.pl --man # METHODS ## croak Call Carp::croak dynamically # IMPORTED METHODS The list of the methods automatically imported into your class. ## new\_with\_options It will parse your command line params and your inline params, validate and call the `new` method. myTool --str=ko t->new_with_options()->str # ko t->new_with_options(str => 'ok')->str #ok ## option The `option` keyword replaces the `has` method and adds support for special options for the command line only. See ["OPTION PARAMETERS"](#option-parameters) for the documentation. ## options\_usage | --help It displays the usage message and returns the exit code. my $t = t->new_with_options(); my $exit_code = 1; my $pre_message = "str is not valid"; $t->options_usage($exit_code, $pre_message); This method is also automatically fired if the command option "--help" is passed. myTool --help ## options\_man | --man It displays the manual. my $t = t->new_with_options(); $t->options_man(); This is automatically fired if the command option "--man" is passed. myTool --man ## options\_short\_usage | --usage It displays a short version of the help message. my $t = t->new_with_options(); $t->options_short_usage($exit_code); This is automatically fired if the command option "--usage" is passed. myTool --usage # IMPORT PARAMETERS The list of parameters supported by [MooX::Options](https://metacpan.org/pod/MooX::Options). ## flavour Passes extra arguments for [Getopt::Long::Descriptive](https://metacpan.org/pod/Getopt::Long::Descriptive). It is useful if you want to configure [Getopt::Long](https://metacpan.org/pod/Getopt::Long). use MooX::Options flavour => [qw( pass_through )]; Any flavour is passed to [Getopt::Long](https://metacpan.org/pod/Getopt::Long) as a configuration, check the doc to see what is possible. ## protect\_argv By default, `@ARGV` is protected. If you want to do something else on it, use this option and it will change the real `@ARGV`. use MooX::Options protect_argv => 0; ## skip\_options If you have Role with options and you want to deactivate some of them, you can use this parameter. In that case, the `option` keyword will just work like an `has`. use MooX::Options skip_options => [qw/multi/]; ## prefer\_commandline By default, arguments passed to `new_with_options` have a higher priority than the command line options. This parameter will give the command line an higher priority. use MooX::Options prefer_commandline => 1; ## with\_config\_from\_file This parameter will load [MooX::ConfigFromFile](https://metacpan.org/pod/MooX::ConfigFromFile) in your module. The config option will be used between the command line and parameters. myTool : use MooX::Options with_config_from_file => 1; In /etc/myTool.json {"test" : 1} # usage\_string This parameter is passed to Getopt::Long::Descriptive::describe\_options() as the first parameter. It is a "sprintf"-like string that is used in generating the first line of the usage message. It's a one-line summary of how the command is to be invoked. The default value is "USAGE: %c %o". %c will be replaced with what Getopt::Long::Descriptive thinks is the program name (it's computed from $0, see "prog\_name"). %o will be replaced with a list of the short options, as well as the text "\[long options...\]" if any have been defined. The rest of the usage description can be used to summarize what arguments are expected to follow the program's options, and is entirely free-form. Literal "%" characters will need to be written as "%%", just like with "sprintf". ## spacer This indicate the char to use for spacer. Please only use 1 char otherwize the text will be too long. The default char is " ". use MooX::Options space => '+' Then the "spacer\_before" and "spacer\_after" will use it for "man" and "help" message. option 'x' => (is => 'ro', spacer_before => 1, spacer_after => 1); # OPTION PARAMETERS The keyword `option` extend the keyword `has` with specific parameters for the command line. ## doc | documentation Documentation for the command line option. ## long\_doc Documentation for the man page. By default the `doc` parameter will be used. See also [Man parameters](https://metacpan.org/pod/MooX::Options::Manual::Man) to get more examples how to build a nice man page. ## required This attribute indicates that the parameter is mandatory. This attribute is not really used by [MooX::Options](https://metacpan.org/pod/MooX::Options) but ensures that consistent error message will be displayed. ## format Format of the params, same as [Getopt::Long::Descriptive](https://metacpan.org/pod/Getopt::Long::Descriptive). - i : integer - i@: array of integer - s : string - s@: array of string - f : float value By default, it's a boolean value. Take a look of available formats with [Getopt::Long::Descriptive](https://metacpan.org/pod/Getopt::Long::Descriptive). You need to understand that everything is explicit here. If you use [Moose](https://metacpan.org/pod/Moose) and your attribute has `isa => 'Array[Int]'`, that will **not** imply the format `i@`. ## format json : special format support The parameter will be treated like a json string. option 'hash' => (is => 'ro', json => 1); You can also use the json format option 'hash' => (is => 'ro', format => "json"); myTool --hash='{"a":1,"b":2}' # hash = { a => 1, b => 2 } ## negativable It adds the negative version for the option. option 'verbose' => (is => 'ro', negativable => 1); myTool --verbose # verbose = 1 myTool --no-verbose # verbose = 0 ## repeatable It appends to the ["format"](#format) the array attribute `@`. I advise to add a default value to your attribute to always have an array. Otherwise the default value will be an undefined value. option foo => (is => 'rw', format => 's@', default => sub { [] }); myTool --foo="abc" --foo="def" # foo = ["abc", "def"] ## autosplit For repeatable option, you can add the autosplit feature with your specific parameters. option test => (is => 'ro', format => 'i@', default => sub {[]}, autosplit => ','); myTool --test=1 --test=2 # test = (1, 2) myTool --test=1,2,3 # test = (1, 2, 3) It will also handle quoted params with the autosplit. option testStr => (is => 'ro', format => 's@', default => sub {[]}, autosplit => ','); myTool --testStr='a,b,"c,d",e,f' # testStr ("a", "b", "c,d", "e", "f") ## autorange For another repeatable option you can add the autorange feature with your specific parameters. This allows you to pass number ranges instead of passing each individual number. option test => (is => 'ro', format => 'i@', default => sub {[]}, autorange => 1); myTool --test=1 --test=2 # test = (1, 2) myTool --test=1,2,3 # test = (1, 2, 3) myTool --test=1,2,3..6 # test = (1, 2, 3, 4, 5, 6) It will also handle quoted params like `autosplit`, and will not rangify them. option testStr => (is => 'ro', format => 's@', default => sub {[]}, autorange => 1); myTool --testStr='1,2,"3,a,4",5' # testStr (1, 2, "3,a,4", 5) `autosplit` will be set to ',' if undefined. You may set `autosplit` to a different delimiter than ',' for your group separation, but the range operator '..' cannot be changed. option testStr => (is => 'ro', format => 's@', default => sub {[]}, autorange => 1, autosplit => '-'); myTool --testStr='1-2-3-5..7' # testStr (1, 2, 3, 5, 6, 7) ## short Long option can also have short version or aliased. option 'verbose' => (is => 'ro', short => 'v'); myTool --verbose # verbose = 1 myTool -v # verbose = 1 option 'account_id' => (is => 'ro', format => 'i', short => 'a|id'); myTool --account_id=1 myTool -a=1 myTool --id=1 You can also use a shorter option without attribute : option 'account_id' => (is => 'ro', format => 'i'); myTool --acc=1 myTool --account=1 ## order Specifies the order of the attribute. If you want to push some attributes at the end of the list. By default all options have an order set to `0`, and options are sorted by their names. option 'at_the_end' => (is => 'ro', order => 999); ## hidden Hide option from doc but still an option you can use on command line. option 'debug' => (is => 'ro', doc => 'hidden'); Or option 'debug' => (is => 'ro', hidden => 1); ## spacer\_before, spacer\_after Add spacer before or after or both the params option 'myoption' => (is => 'ro', spacer_before => 1, spacer_after => 1); # ADDITIONAL MANUALS - [Man parameters](https://metacpan.org/pod/MooX::Options::Manual::Man) - [Using namespace::clean](https://metacpan.org/pod/MooX::Options::Manual::NamespaceClean) - [Manage your tools with MooX::Cmd](https://metacpan.org/pod/MooX::Options::Manual::MooXCmd) # EXTERNAL EXAMPLES - [Slide3D about MooX::Options](http://perltalks.celogeek.com/slides/2012/08/moox-options-slide3d.html) # Translation Translation is now supported. Use the dzil command to update the pot and merge into the po files. - dzil msg-init Create a new language po - dzil msg-scan Scan and generate or update the pot file - dzil msg-merge Update all languages using the pot file ## THANKS - sschober For implementation and German translation. # THANKS - Matt S. Trout (mst) For his patience and advice. - Tomas Doran (t0m) To help me release the new version, and using it :) - Torsten Raudssus (Getty) to use it a lot in [DuckDuckGo](http://duckduckgo.com) (go to see [MooX](https://metacpan.org/pod/MooX) module also) - Jens Rehsack (REHSACK) Use with [PkgSrc](http://www.pkgsrc.org/), and many really good idea ([MooX::Cmd](https://metacpan.org/pod/MooX::Cmd), [MooX::ConfigFromFile](https://metacpan.org/pod/MooX::ConfigFromFile), and more to come I'm sure) - All contributors For improving and add more feature to MooX::Options # BUGS Please report any bugs or feature requests on the bugtracker website https://github.com/celogeek/MooX-Options/issues When submitting a bug or request, please include a test-file or a patch to an existing test-file that illustrates the bug or desired feature. # AUTHOR celogeek # COPYRIGHT AND LICENSE This software is copyright (c) 2013 by celogeek . This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. flavour.t100644001751001751 506012741266240 14752 0ustar00devdev000000000000MooX-Options-4.023/t#!/usr/bin/env perl # # This file is part of MooX-Options # # This software is copyright (c) 2013 by celogeek . # # This is free software; you can redistribute it and/or modify it under # the same terms as the Perl 5 programming language system itself. # use t::Test; use Test::Trap; use Carp; use FindBin qw/$RealBin/; use Try::Tiny; local $ENV{TEST_FORCE_COLUMN_SIZE} = 78; { package plain; use Moo; use MooX::Options protect_argv => 0; option 'bool' => ( is => 'ro' ); 1; } { package plain2; use Moo; use MooX::Options protect_argv => 0, flavour => undef; option 'bool' => ( is => 'ro' ); 1; } { package FlavourTest; use Moo; use MooX::Options flavour => [qw(pass_through)], protect_argv => 0; option 'bool' => ( is => 'ro' ); 1; } for my $noflavour (qw/plain plain2/) { subtest "unknown option $noflavour" => sub { note "Without flavour $noflavour"; { local @ARGV = ('anarg'); my $plain = $noflavour->new_with_options(); is_deeply( [@ARGV], ['anarg'], "anarg is left" ); } { local @ARGV = ( '--bool', 'anarg' ); my $plain = $noflavour->new_with_options(); is( $plain->bool, 1, "bool was set" ); is_deeply( [@ARGV], ['anarg'], "anarg is left" ); } { local @ARGV = ( '--bool', 'anarg', '--unknown_option' ); my @r = trap { $noflavour->new_with_options() }; is( $trap->exit, 1, "exit code ok" ); like( $trap->stderr, qr/Unknown option: unknown_option/, "and a warning from GLD" ); like( $trap->stderr, qr/USAGE:/, "died with usage message" ); } }; } subtest "flavour" => sub { note "With flavour"; { local @ARGV = ('anarg'); my $flavour_test = FlavourTest->new_with_options(); is_deeply( [@ARGV], ['anarg'], "anarg is left" ); } { local @ARGV = ( '--bool', 'anarg' ); my $flavour_test = FlavourTest->new_with_options(); is( $flavour_test->bool, 1, "bool was set" ); is_deeply( [@ARGV], ['anarg'], "anarg is left" ); } { local @ARGV = ( '--bool', 'anarg', '--unknown_option' ); my $flavour_test = FlavourTest->new_with_options(); is( $flavour_test->bool, 1, "bool was set" ); is_deeply( [@ARGV], [ 'anarg', '--unknown_option' ], "anarg and unknown_option are left" ); } }; done_testing; failure.t100644001751001751 566312741266240 14734 0ustar00devdev000000000000MooX-Options-4.023/t#!/usr/bin/env perl # # This file is part of MooX-Options # # This software is copyright (c) 2013 by celogeek . # # This is free software; you can redistribute it and/or modify it under # the same terms as the Perl 5 programming language system itself. # use t::Test; use Carp; local $ENV{TEST_FORCE_COLUMN_SIZE} = 78; eval <<__EOF__ package FailureNegativableWithFormat; use Moo; use MooX::Options; option fail => ( is => 'rw', negativable => 1, format => 'i', ); 1; __EOF__ ; like $@, qr/^Negativable\sparams\sis\snot\susable\swith\snon\sboolean\svalue,\sdon't\spass\sformat\sto\suse\sit\s\!/x, "negativable and format are incompatible"; for my $ban ( qw/help man usage option new_with_options parse_options options_usage _options_data _options_config/ ) { eval <<__EOF__ package FailureHelp$ban; use Moo; use MooX::Options; option $ban => ( is => 'rw', ); __EOF__ ; like $@, qr/^You\scannot\suse\san\soption\swith\sthe\sname\s'$ban',\sit\sis\simplied\sby\sMooX::Options/x, "$ban method can't be defined"; } { eval <<__EOF__ { package FailureRoleMyRole; use Moo::Role; use MooX::Options; option 't' => (is => 'rw'); 1; } { package FailureRole; use Moo; with 'FailureRoleMyRole'; 1; } __EOF__ ; like $@, qr/^Can't\sapply\sFailureRoleMyRole\sto\sFailureRole\s-\smissing\s_options_data,\s_options_config/x, "role could only be apply with a MooX::Options ready package" } { eval <<__EOF__ { package t; use Moo; sub _options_data {}; sub _options_config {}; use MooX::Options; 1; } __EOF__ ; like $@, qr/^Subroutine\s_options_data\sredefined/x, 'redefined methods'; ok( !t->can('new_with_options'), 't has crash' ); } { eval <<__EOF__ { package MissingWith; use MooX::Options; 1; } __EOF__ ; like $@, qr/^\QCan't find the method in ! Ensure to load a Role::Tiny compatible module like Moo or Moose before using MooX::Options.\E/, 'missing with'; } { eval <<__EOF__ { package MissingAround; sub with {}; use MooX::Options; 1; } __EOF__ ; like $@, qr/^\QCan't find the method in ! Ensure to load a Role::Tiny compatible module like Moo or Moose before using MooX::Options.\E/, 'missing with'; } { eval <<__EOF__ { package MissingHas; sub with {}; sub around {}; use MooX::Options; 1; } __EOF__ ; like $@, qr/^\QCan't find the method in ! Ensure to load a Role::Tiny compatible module like Moo or Moose before using MooX::Options.\E/, 'missing with'; } done_testing; de_DE.po100644001751001751 737312741266240 14573 0ustar00devdev000000000000MooX-Options-4.023/po# German translations for MooX-Options package # German translation for MooX-Options. # Copyright (C) 2015 celogeek # This file is distributed under the same license as the MooX-Options package. # Automatically generated, 2015. # msgid "" msgstr "" "Project-Id-Version: MooX-Options 4.019\n" "Report-Msgid-Bugs-To: me@celogeek.com\n" "POT-Creation-Date: 2015-05-01 13:45+0400\n" "PO-Revision-Date: 2015-05-01 13:46+0400\n" "Last-Translator: Automatically generated\n" "Language-Team: none\n" "Language: de\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "Plural-Forms: nplurals=2; plural=(n != 1);\n" "X-Generator: Poedit 1.7.4\n" #: lib/MooX/Options.pm:102 #, perl-brace-format msgid "" "Can't find the method <{needed_methods}> in <{target}> ! Ensure to load a " "Role::Tiny compatible module like Moo or Moose before using MooX::Options." msgstr "" "Kann die Methode <{needed_methods}> nicht in <{target}> finden! Stellen Sie " "sicher, dass ein Role::Tiny kompatibles Modul, wie Moo oder Moose geladen " "ist, bevor Sie MooX::Options benutzen." #: lib/MooX/Options.pm:147 msgid "Please, don't use the option into a role." msgstr "" "Bitte, komponieren Sie die Option nicht in eine " "Rolle." #: lib/MooX/Options.pm:191 #, perl-brace-format msgid "" "You cannot use an option with the name '{ban}', it is implied by MooX::" "Options" msgstr "" "Sie können eine Option mit Namen '{ban}' nicht einsetzen, da diese bereits " "von MooX::Options impliziert wird." #: lib/MooX/Options.pm:250 msgid "" "Negativable params is not usable with non boolean value, don't pass format " "to use it !" msgstr "" "Ungültige Formatspezifikation. Negierbare Parameter sind mit Bool'schen " "Werten nicht einsetzbar." #: lib/MooX/Options/Descriptive/Usage.pm:38 #: lib/MooX/Options/Descriptive/Usage.pm:51 msgid "String" msgstr "Zeichenkette" #: lib/MooX/Options/Descriptive/Usage.pm:39 msgid "[Strings]" msgstr "[Zeichenketten]" #: lib/MooX/Options/Descriptive/Usage.pm:40 msgid "Int" msgstr "Ganzzahl" #: lib/MooX/Options/Descriptive/Usage.pm:41 msgid "[Ints]" msgstr "[Ganzzahlen]" #: lib/MooX/Options/Descriptive/Usage.pm:42 msgid "Ext. Int" msgstr "Erw. Ganzzahl" #: lib/MooX/Options/Descriptive/Usage.pm:43 msgid "[Ext. Ints]" msgstr "[Erw. Ganzzahl]" #: lib/MooX/Options/Descriptive/Usage.pm:44 msgid "Real" msgstr "Reelle Zahl" #: lib/MooX/Options/Descriptive/Usage.pm:45 msgid "[Reals]" msgstr "[Reelle Zahlen]" #: lib/MooX/Options/Descriptive/Usage.pm:52 msgid "Array of Strings" msgstr "Array von Zeichenketten" #: lib/MooX/Options/Descriptive/Usage.pm:53 msgid "Integer" msgstr "Ganzzahl" #: lib/MooX/Options/Descriptive/Usage.pm:54 msgid "Array of Integers" msgstr "" #: lib/MooX/Options/Descriptive/Usage.pm:55 msgid "Extended Integer" msgstr "Erweiterte Ganzzahl" #: lib/MooX/Options/Descriptive/Usage.pm:56 msgid "Array of extended integers" msgstr "" #: lib/MooX/Options/Descriptive/Usage.pm:57 msgid "Real number" msgstr "Reelle Zahl" #: lib/MooX/Options/Descriptive/Usage.pm:58 msgid "Array of real numbers" msgstr "" #: lib/MooX/Options/Descriptive/Usage.pm:113 msgid "SUB COMMANDS AVAILABLE: " msgstr "Verfügbare Unterkommandos: " #: lib/MooX/Options/Descriptive/Usage.pm:211 #: lib/MooX/Options/Descriptive/Usage.pm:250 msgid "long options ..." msgstr "Langoptionen ..." #: lib/MooX/Options/Role.pm:314 #, perl-format, perl-brace-format msgid "USAGE: {prog_name} %o" msgstr "Aufruf: {prog_name} %o" #: lib/MooX/Options/Role.pm:320 msgid "show a short help message" msgstr "Zeige einen kurzen Hilfetext" #: lib/MooX/Options/Role.pm:321 msgid "show a help message" msgstr "Zeige einen Hilfetext" #: lib/MooX/Options/Role.pm:322 msgid "show the manual" msgstr "Zeige das Handbuch" coverage.txt100644001751001751 127612741266240 15205 0ustar00devdev000000000000MooX-Options-4.023---------------------------- ------ ------ ------ ------ ------ ------ ------ File stmt bran cond sub pod time total ---------------------------- ------ ------ ------ ------ ------ ------ ------ blib/lib/MooX/Options.pm 100.0 100.0 100.0 100.0 n/a 47.6 100.0 ...oX/Options/Descriptive.pm 100.0 n/a n/a 100.0 100.0 6.8 100.0 ...ions/Descriptive/Usage.pm 93.3 80.0 55.0 86.3 100.0 11.8 86.1 .../lib/MooX/Options/Role.pm 97.4 93.5 70.8 100.0 100.0 33.6 93.5 Total 97.3 90.8 71.2 96.8 100.0 100.0 93.5 ---------------------------- ------ ------ ------ ------ ------ ------ ------ moox-cmd.t100644001751001751 606012741266240 15020 0ustar00devdev000000000000MooX-Options-4.023/t#!perl # # This file is part of MooX-Options # # This software is copyright (c) 2013 by celogeek . # # This is free software; you can redistribute it and/or modify it under # the same terms as the Perl 5 programming language system itself. # use t::Test; use Test::Trap; use Carp; use FindBin qw/$RealBin/; use Capture::Tiny qw/capture/; BEGIN { eval 'use MooX::Cmd 0.007'; if ($@) { plan skip_all => 'Need MooX::Cmd (0.007) for this test'; exit 0; } } use t::lib::MooXCmdTest; trap { local @ARGV = ('-h'); t::lib::MooXCmdTest->new_with_cmd; }; like $trap->stdout, qr{\QUSAGE: moox-cmd.t [-h]\E}, 'base command help ok'; like $trap->stdout, qr{\QSUB COMMANDS AVAILABLE: test1, test3\E}, 'sub base command help ok'; trap { t::lib::MooXCmdTest->new->options_man( undef, *STDOUT ); }; like $trap->stdout, qr{NAME\s+\Qmoox-cmd.t\E}, 'pod name ok'; like $trap->stdout, qr{DESCRIPTION\s+\QThis is a test sub command\E}, 'pod description ok'; like $trap->stdout, qr{SYNOPSIS\s+\Qmoox-cmd.t [-h] [long options ...]\E\s+\QThis is a test synopsis\E}, 'pod synopsis ok'; like $trap->stdout, qr{AUTHORS\s+\QCelogeek \E}, 'pod author ok'; trap { local @ARGV = ( 'test1', '-h' ); t::lib::MooXCmdTest->new_with_cmd(); }; like $trap->stdout, qr{\QUSAGE: moox-cmd.t test1 [-h]\E}, 'subcommand 1 help ok'; like $trap->stdout, qr{\QSUB COMMANDS AVAILABLE: test2\E}, 'sub subcommand 1 help ok'; trap { local @ARGV = ( 'test1', '-h' ); t::lib::MooXCmdTest->new_with_options( command_chain => [] ); }; like $trap->stdout, qr{\QUSAGE: moox-cmd.t [-h]\E}, 'no subcommand pass'; trap { local @ARGV = ( 'test1', '-h' ); t::lib::MooXCmdTest->new_with_options( command_chain => [123] ); }; like $trap->stdout, qr{\QUSAGE: moox-cmd.t [-h]\E}, 'no ref params'; trap { local @ARGV = ( 'test1', '-h' ); t::lib::MooXCmdTest->new_with_options( command_chain => [ {} ] ); }; like $trap->stdout, qr{\QUSAGE: moox-cmd.t [-h]\E}, 'bad ref'; trap { local @ARGV = ( 'test1', '-h' ); t::lib::MooXCmdTest->new_with_options( command_chain => [ bless {}, 'MooX::Cmd' ] ); }; like $trap->stdout, qr{\QUSAGE: moox-cmd.t [-h]\E}, 'bad ref'; trap { local @ARGV = ( 'test1', '-h' ); t::lib::MooXCmdTest->new_with_options( command_chain => [ t::lib::MooXCmdTest->new ] ); }; like $trap->stdout, qr{\QUSAGE: moox-cmd.t [-h]\E}, 'no command_name filled'; trap { local @ARGV = ( 'test1', '-h' ); t::lib::MooXCmdTest->new_with_options( command_chain => [ t::lib::MooXCmdTest->new( command_name => 'mySub' ) ], command_commands => { a => 1, b => 2 } ); }; like $trap->stdout, qr{\QUSAGE: moox-cmd.t mySub [-h]\E}, 'subcommand with mySub name'; like $trap->stdout, qr{\QSUB COMMANDS AVAILABLE: a, b\E}, 'sub subcommand with mySub name'; trap { local @ARGV = ( 'test1', 'test2', '-h' ); t::lib::MooXCmdTest->new_with_cmd; }; like $trap->stdout, qr{\QUSAGE: moox-cmd.t test1 test2 [-h]\E}, 'subcommand 2 ok'; done_testing; doc-utf8.t100644001751001751 172112741266240 14725 0ustar00devdev000000000000MooX-Options-4.023/t#!perl # # This file is part of MooX-Options # # This software is copyright (c) 2013 by celogeek . # # This is free software; you can redistribute it and/or modify it under # the same terms as the Perl 5 programming language system itself. # use t::Test; use Test::Trap; use Carp; use FindBin qw/$RealBin/; use Try::Tiny; local $ENV{TEST_FORCE_COLUMN_SIZE} = 78; { package t; use Moo; use MooX::Options; option 't' => ( is => 'ro', documentation => 'this is a test with utf8 : ça marche héhé !', ); 1; } { my $opt = t->new_with_options; trap { $opt->options_usage }; like $trap->stdout, qr/\s+\-t\s+this\sis\sa\stest\swith\sutf8\s:\sça\smarche\shéhé\s\!/x, 'documentation work'; trap { $opt->options_help }; like $trap->stdout, qr/\s+\-t:\n\s+this\sis\sa\stest\swith\sutf8\s:\sça\smarche\shéhé\s\!/x, 'documentation work'; } done_testing; no_option.t100644001751001751 70312741266240 15257 0ustar00devdev000000000000MooX-Options-4.023/t#!perl # # This file is part of MooX-Options # # This software is copyright (c) 2013 by celogeek . # # This is free software; you can redistribute it and/or modify it under # the same terms as the Perl 5 programming language system itself. # use t::Test; local $ENV{TEST_FORCE_COLUMN_SIZE} = 78; { package t; use Moo; use MooX::Options; 1; } my $p = t->new_with_options; ok( $p, 't has options' ); done_testing; isa_check.t100644001751001751 135412741266240 15207 0ustar00devdev000000000000MooX-Options-4.023/t#!perl # # This file is part of MooX-Options # # This software is copyright (c) 2013 by celogeek . # # This is free software; you can redistribute it and/or modify it under # the same terms as the Perl 5 programming language system itself. # use t::Test; use Test::Trap; { package t; use strict; use warnings; use Moo; use MooX::Options; option 'hero' => ( is => 'ro', doc => 'this is mandatory', format => 's@', isa => sub { die "boop\n" }, ); 1; } { local @ARGV = (qw/--hero batman/); trap { my $opt = t->new_with_options(); }; like $trap->stderr, qr/^boop/, 'stdout ok'; like $trap->stderr, qr/USAGE/, 'stderr ok'; } done_testing; xt000755001751001751 012741266240 13136 5ustar00devdev000000000000MooX-Options-4.023perltidy.rc100644001751001751 31512741266240 15437 0ustar00devdev000000000000MooX-Options-4.023/xt#Perl Best Practice Conf -l=78 -i=4 -ci=4 #-st -se -vt=2 -cti=0 -pt=1 -bt=1 -sbt=1 -bbt=1 -nsfs -nolq -wbb="% + - * / x != == >= <= =~ !~ < > | & >= < = **= += *= &= <<= &&= -= /= |= >>= ||= .= %= ^= x=" multi_role.t100644001751001751 201512741266240 15444 0ustar00devdev000000000000MooX-Options-4.023/t#!perl # # This file is part of MooX-Options # # This software is copyright (c) 2013 by celogeek . # # This is free software; you can redistribute it and/or modify it under # the same terms as the Perl 5 programming language system itself. # use t::Test; use Test::Trap; local $ENV{TEST_FORCE_COLUMN_SIZE} = 78; { package r1Role; use Moo::Role; use MooX::Options; option 'r1' => ( is => 'ro' ); 1; } { package r2Role; use Moo::Role; use MooX::Options; option 'r2' => ( is => 'ro' ); 1; } { package t; use Moo; use MooX::Options; with 'r1Role', 'r2Role'; option 'r3' => ( is => 'ro' ); 1 } local @ARGV = ( '--r1', '--r2', '--r3' ); my $r; $r = t->new_with_options; ok( $r, 'r is defined' ); if ( defined $r ) { ok( $r->can('r1'), 'r1 exists' ); ok( $r->can('r2'), 'r2 exists' ); ok( $r->can('r3'), 'r3 exists' ); ok( $r->r1(), 'r1 set' ); ok( $r->r2(), 'r2 set' ); ok( $r->r3(), 'r3 set' ); } done_testing; 00-compile.t100644001751001751 246312741266240 15145 0ustar00devdev000000000000MooX-Options-4.023/tuse 5.006; use strict; use warnings; # this test was generated with Dist::Zilla::Plugin::Test::Compile 2.053 use Test::More; plan tests => 4 + ($ENV{AUTHOR_TESTING} ? 1 : 0); my @module_files = ( 'MooX/Options.pm', 'MooX/Options/Descriptive.pm', 'MooX/Options/Descriptive/Usage.pm', 'MooX/Options/Role.pm' ); # no fake home requested my $inc_switch = -d 'blib' ? '-Mblib' : '-Ilib'; use File::Spec; use IPC::Open3; use IO::Handle; open my $stdin, '<', File::Spec->devnull or die "can't open devnull: $!"; my @warnings; for my $lib (@module_files) { # see L my $stderr = IO::Handle->new; my $pid = open3($stdin, '>&STDERR', $stderr, $^X, $inc_switch, '-e', "require q[$lib]"); binmode $stderr, ':crlf' if $^O eq 'MSWin32'; my @_warnings = <$stderr>; waitpid($pid, 0); is($?, 0, "$lib loaded ok"); shift @_warnings if @_warnings and $_warnings[0] =~ /^Using .*\bblib/ and not eval { blib->VERSION('1.01') }; if (@_warnings) { warn @_warnings; push @warnings, @_warnings; } } is(scalar(@warnings), 0, 'no warnings found') or diag 'got warnings: ', ( Test::More->can('explain') ? Test::More::explain(\@warnings) : join("\n", '', @warnings) ) if $ENV{AUTHOR_TESTING}; with_config.t100644001751001751 524012741266240 15574 0ustar00devdev000000000000MooX-Options-4.023/t#!perl # # This file is part of MooX-Options # # This software is copyright (c) 2013 by celogeek . # # This is free software; you can redistribute it and/or modify it under # the same terms as the Perl 5 programming language system itself. # use t::Test; use Test::Trap; local $ENV{TEST_FORCE_COLUMN_SIZE} = 78; { package MyTestWithConfig; use Moo; use MooX::Options with_config_from_file => 1; option 'p1' => ( is => 'ro', format => 'i', required => 1 ); option 'p2' => ( is => 'ro', format => 'i@', required => 1 ); 1; } my $t = MyTestWithConfig->new_with_options(); is $t->p1, 1, 'p1 fetch from config'; is_deeply $t->p2, [ 1, 2, 3 ], '... and also p2'; ok $t->can('config_prefix'), '... config prefix defined'; ok $t->can('config_dirs'), '... config dirs defined'; ok $t->can('config_files'), '... config files defined'; { local @ARGV = ( '--config_prefix', 'with_config_2.t' ); my $t = MyTestWithConfig->new_with_options(); is $t->p1, 2, 'p1 fetch from config'; is_deeply $t->p2, [ 3, 4, 5 ], '... and also p2'; } { local @ARGV = ( '--p1', '2' ); my $t = MyTestWithConfig->new_with_options(); is $t->p1, 2, 'p1 fetch from cmdline'; is_deeply $t->p2, [ 1, 2, 3 ], '... and p2 from config'; } { local @ARGV = ( '--p1', '2' ); my $t = MyTestWithConfig->new_with_options( p1 => 3 ); is $t->p1, 3, 'p1 fetch from params'; is_deeply $t->p2, [ 1, 2, 3 ], '... and p2 from config'; } eval < 1; option 'p1' => (is => 'ro', format => 'i', required => 1); option 'p2' => (is => 'ro', format => 'i\@', required => 1); 1; EOF ; like $@, qr/\QPlease, don't use the option into a role.\E/x, 'error when try to include with_config_from_file into a role'; eval < 1; option 'p1' => (is => 'ro', format => 'i', required => 1); option 'p2' => (is => 'ro', format => 'i\@', required => 1); option 'config_files' => (is => 'ro'); 1; EOF ; like $@, qr/\QYou cannot use an option with the name 'config_files', it is implied by MooX::Options\E/x, 'keywords when we use config is bannish'; eval < 0; option 'p1' => (is => 'ro', format => 'i', required => 1); option 'p2' => (is => 'ro', format => 'i\@', required => 1); option 'config_files' => (is => 'ro'); 1; EOF ; ok !$@, '... and not without the config option'; done_testing; perlcritic.rc100644001751001751 110712741266240 15763 0ustar00devdev000000000000MooX-Options-4.023/xtseverity = 3 verbose = 6 top = 50 theme = pbp || core || bugs || security || maintenance criticism-fatal = 1 color = 1 allow-unsafe = 1 [TestingAndDebugging::ProhibitNoStrict] allow = refs [Variables::RequireLocalizedPunctuationVars] allow = @ARGV [-Miscellanea::ProhibitUnrestrictedNoCritic] [Variables::ProhibitPackageVars] add_packages = Text::WrapI18N [-Subroutines::ProhibitBuiltinHomonyms] [Subroutines::ProhibitUnusedPrivateSubroutines] allow=_options_sub_commands [ControlStructures::ProhibitCascadingIfElse] max_elsif = 10 usage_string.t100644001751001751 140312741266240 15763 0ustar00devdev000000000000MooX-Options-4.023/t#!perl # # This file is part of MooX-Options # # This software is copyright (c) 2013 by celogeek . # # This is free software; you can redistribute it and/or modify it under # the same terms as the Perl 5 programming language system itself. # use t::Test; use Test::Trap; { package t; use strict; use warnings; use Moo; use MooX::Options usage_string => 'usage: myprogram %o'; option 'hero' => ( is => 'ro', doc => 'this is mandatory', format => 's@', ); 1; } { local @ARGV = (qw/--bad-option/); trap { my $opt = t->new_with_options(); }; like $trap->stderr, qr/usage: myprogram \[-h\] \[long options/, 'stderr has correct usage'; } done_testing; author-critic.t100644001751001751 132712741266240 16053 0ustar00devdev000000000000MooX-Options-4.023/t#!perl # # This file is part of MooX-Options # # This software is copyright (c) 2013 by celogeek . # # This is free software; you can redistribute it and/or modify it under # the same terms as the Perl 5 programming language system itself. # BEGIN { unless ( $ENV{AUTHOR_TESTING} ) { require Test::More; Test::More::plan( skip_all => 'these tests are for testing by the author' ); } } use strict; use warnings; use Test::More; use English qw(-no_match_vars); eval "use Test::Perl::Critic"; plan skip_all => 'Test::Perl::Critic required to criticise code' if $@; Test::Perl::Critic->import( -profile => "xt/perlcritic.rc" ) if -e "xt/perlcritic.rc"; all_critic_ok(); MooX000755001751001751 012741266240 14133 5ustar00devdev000000000000MooX-Options-4.023/libOptions.pm100755001751001751 4245312741266240 16317 0ustar00devdev000000000000MooX-Options-4.023/lib/MooX# # This file is part of MooX-Options # # This software is copyright (c) 2013 by celogeek . # # This is free software; you can redistribute it and/or modify it under # the same terms as the Perl 5 programming language system itself. # package MooX::Options; # ABSTRACT: Explicit Options eXtension for Object Class use strict; use warnings; our $VERSION = '4.023'; # VERSION use Locale::TextDomain 'MooX-Options'; my @OPTIONS_ATTRIBUTES = qw/format short repeatable negativable autosplit autorange doc long_doc order json hidden spacer_before spacer_after/; sub import { my ( undef, @import ) = @_; my $options_config = { protect_argv => 1, flavour => [], skip_options => [], prefer_commandline => 0, with_config_from_file => 0, usage_string => undef, #long description (manual) description => undef, authors => [], synopsis => undef, spacer => " ", @import }; my $target = caller; for my $needed_methods (qw/with around has/) { next if $target->can($needed_methods); croak( __x("Can't find the method <{needed_methods}> in <{target}> ! Ensure to load a Role::Tiny compatible module like Moo or Moose before using MooX::Options.", 'needed_methods' => $needed_methods, 'target' => $target ) ); } my $with = $target->can('with'); my $around = $target->can('around'); my $has = $target->can('has'); my @target_isa; { no strict 'refs'; @target_isa = @{"${target}::ISA"} }; if (@target_isa) { #only in the main class, not a role use warnings FATAL => 'redefine'; ## no critic (ProhibitStringyEval, ErrorHandling::RequireCheckingReturnValueOfEval, ValuesAndExpressions::ProhibitImplicitNewlines) eval '{ package ' . $target . '; sub _options_data { my ( $class, @meta ) = @_; return $class->maybe::next::method(@meta); } sub _options_config { my ( $class, @params ) = @_; return $class->maybe::next::method(@params); } 1; }'; use warnings FATAL => qw/void/; croak($@) if $@; $around->( _options_config => sub { my ( $orig, $self ) = ( shift, shift ); return $self->$orig(@_), %$options_config; } ); ## use critic } else { if ( $options_config->{with_config_from_file} ) { croak( __( "Please, don\'t use the option into a role." ) ); } } my $options_data = {}; if ( $options_config->{with_config_from_file} ) { $options_data->{config_prefix} = { format => 's', doc => 'config prefix', order => 0, }; $options_data->{config_files} = { format => 's@', doc => 'config files', order => 0, }; } my $apply_modifiers = sub { return if $target->can('new_with_options'); $with->('MooX::Options::Role'); if ( $options_config->{with_config_from_file} ) { $with->('MooX::ConfigFromFile::Role'); } $around->( _options_data => sub { my ( $orig, $self ) = ( shift, shift ); return ( $self->$orig(@_), %$options_data ); } ); }; my @banish_keywords = qw/h help man usage option new_with_options parse_options options_usage _options_data _options_config/; if ( $options_config->{with_config_from_file} ) { push @banish_keywords, qw/config_files config_prefix config_dirs/; } my $option = sub { my ( $name, %attributes ) = @_; for my $ban (@banish_keywords) { croak( __x("You cannot use an option with the name '{ban}', it is implied by MooX::Options", ban => $ban ) ) if $name eq $ban; } $has->( $name => _filter_attributes(%attributes) ); $options_data->{$name} = { _validate_and_filter_options(%attributes) }; $apply_modifiers->(); return; }; if ( my $info = $Role::Tiny::INFO{$target} ) { $info->{not_methods}{$option} = $option; } { no strict 'refs'; *{"${target}::option"} = $option; } $apply_modifiers->(); return; } sub _filter_attributes { my %attributes = @_; my %filter_key = map { $_ => 1 } @OPTIONS_ATTRIBUTES; return map { ( $_ => $attributes{$_} ) } grep { !exists $filter_key{$_} } keys %attributes; } sub _validate_and_filter_options { my (%options) = @_; $options{doc} = $options{documentation} if !defined $options{doc}; $options{order} = 0 if !defined $options{order}; $options{autosplit} = ',' if !defined $options{autosplit} && $options{autorange}; if ( $options{json} || ( defined $options{format} && $options{format} eq 'json' ) ) { delete $options{repeatable}; delete $options{autosplit}; delete $options{autorange}; delete $options{negativable}; $options{json} = 1; $options{format} = 's'; } my %cmdline_options = map { ( $_ => $options{$_} ) } grep { exists $options{$_} } @OPTIONS_ATTRIBUTES, 'required'; $cmdline_options{repeatable} = 1 if $cmdline_options{autosplit}; $cmdline_options{format} .= "@" if $cmdline_options{repeatable} && defined $cmdline_options{format} && substr( $cmdline_options{format}, -1 ) ne '@'; croak( __( "Negativable params is not usable with non boolean value, don't pass format to use it !" ) ) if $cmdline_options{negativable} && defined $cmdline_options{format}; return %cmdline_options; } sub croak { require Carp; goto &Carp::croak; } 1; __END__ =pod =head1 NAME MooX::Options - Explicit Options eXtension for Object Class =head1 VERSION version 4.023 =head1 DESCRIPTION Create a command line tool with your L, L, L objects. Everything is explicit. You have an C