dagolden / getopt-lucid Goto Github PK
View Code? Open in Web Editor NEW(Perl) Clear, readable syntax for command line processing
Home Page: http://search.cpan.org/dist/Getopt-Lucid
(Perl) Clear, readable syntax for command line processing
Home Page: http://search.cpan.org/dist/Getopt-Lucid
The negation of switches (and other types) is confusing if argv is strictly parsed.
Switch('--rawdump')->default(1),
and on the command-line: --no-rawdump
results in $opt->get_rawdump
to be still 1. (--no---rawdump
would work but is a bit bizarre imho.)
Switch('--rawdump|rawdump')->default(1),
Than the negation switch --no-rawdump
works as expected.
Should be documented at least or throw an error for the not working negation switch --no-rawdump
.
Just my 2 cents to an otherwise great module.
What we have now is effectively "needs all". What about "needs only one" or "needs any"?
Possibly take a sub reference and let people use Syntax::Keyword::Junction:
use Syntax::Keyword::Junction qw/any one/;
my $spec = [
Param("foo")->needs( sub { $_ eq any(qw/bar baz/) } ),
Param("baz")->needs( sub { $_ eq one(qw/quux wibble/) } ),
];
Or, possibly we just make those individual methods (and use junctions internally):
my $spec = [
Param("foo")->needs_any(qw/bar baz/),
Param("baz")->needs_one(qw/quux wibble/),
];
On 5.25.10 with -Ddefault_inc_excludes_dot
PERL_DL_NONLAZY=1 "/home/kent/perl5/perlbrew/perls/5.25.10-nossp-sdbm-nopmc-nodot/bin/perl5.25.10" "-MExtUtils::Command::MM" "-MTest::Harness" "-e" "undef *Test::Harness::Switches; test_harness(0, 'blib/lib', 'blib/arch')" t/*.t
t/00-new.t ................. ok
t/01-exceptions.t .......... ok
Can't locate t/ErrorMessages.pm in @INC (you may need to install the t::ErrorMessages module) (@INC contains: /home/kent/.cpanm/work/1488218060.1141/Getopt-Lucid-1.07/blib/lib /home/kent/.cpanm/work/1488218060.1141/Getopt-Lucid-1.07/blib/arch /home/kent/.cpanm/work/1488218060.1141/Getopt-Lucid-1.07/blib/lib /home/kent/.cpanm/work/1488218060.1141/Getopt-Lucid-1.07/blib/arch /home/kent/.cpanm/work/1488218060.1141/Getopt-Lucid-1.07/blib/lib /home/kent/.cpanm/work/1488218060.1141/Getopt-Lucid-1.07/blib/arch /home/kent/.cpanm/work/1488218060.1141/Getopt-Lucid-1.07/blib/lib /home/kent/.cpanm/work/1488218060.1141/Getopt-Lucid-1.07/blib/arch /home/kent/perl5/perlbrew/perls/5.25.10-nossp-sdbm-nopmc-nodot/lib/site_perl/5.25.10/x86_64-linux /home/kent/perl5/perlbrew/perls/5.25.10-nossp-sdbm-nopmc-nodot/lib/site_perl/5.25.10 /home/kent/perl5/perlbrew/perls/5.25.10-nossp-sdbm-nopmc-nodot/lib/5.25.10/x86_64-linux /home/kent/perl5/perlbrew/perls/5.25.10-nossp-sdbm-nopmc-nodot/lib/5.25.10) at t/02-getopt.t line 7.
BEGIN failed--compilation aborted at t/02-getopt.t line 7.
t/02-getopt.t ..............
Dubious, test returned 2 (wstat 512, 0x200)
No subtests run
t/03-getopt-notargv.t ...... ok
t/05-accessors.t ........... ok
Can't locate t/ErrorMessages.pm in @INC (you may need to install the t::ErrorMessages module) (@INC contains: /home/kent/.cpanm/work/1488218060.1141/Getopt-Lucid-1.07/blib/lib /home/kent/.cpanm/work/1488218060.1141/Getopt-Lucid-1.07/blib/arch /home/kent/perl5/perlbrew/perls/5.25.10-nossp-sdbm-nopmc-nodot/lib/site_perl/5.25.10/x86_64-linux /home/kent/perl5/perlbrew/perls/5.25.10-nossp-sdbm-nopmc-nodot/lib/site_perl/5.25.10 /home/kent/perl5/perlbrew/perls/5.25.10-nossp-sdbm-nopmc-nodot/lib/5.25.10/x86_64-linux /home/kent/perl5/perlbrew/perls/5.25.10-nossp-sdbm-nopmc-nodot/lib/5.25.10) at t/09-negation.t line 8.
BEGIN failed--compilation aborted at t/09-negation.t line 8.
t/09-negation.t ............
Dubious, test returned 2 (wstat 512, 0x200)
No subtests run
Can't locate t/ErrorMessages.pm in @INC (you may need to install the t::ErrorMessages module) (@INC contains: /home/kent/.cpanm/work/1488218060.1141/Getopt-Lucid-1.07/blib/lib /home/kent/.cpanm/work/1488218060.1141/Getopt-Lucid-1.07/blib/arch /home/kent/.cpanm/work/1488218060.1141/Getopt-Lucid-1.07/blib/lib /home/kent/.cpanm/work/1488218060.1141/Getopt-Lucid-1.07/blib/arch /home/kent/.cpanm/work/1488218060.1141/Getopt-Lucid-1.07/blib/lib /home/kent/.cpanm/work/1488218060.1141/Getopt-Lucid-1.07/blib/arch /home/kent/.cpanm/work/1488218060.1141/Getopt-Lucid-1.07/blib/lib /home/kent/.cpanm/work/1488218060.1141/Getopt-Lucid-1.07/blib/arch /home/kent/.cpanm/work/1488218060.1141/Getopt-Lucid-1.07/blib/lib /home/kent/.cpanm/work/1488218060.1141/Getopt-Lucid-1.07/blib/arch /home/kent/.cpanm/work/1488218060.1141/Getopt-Lucid-1.07/blib/lib /home/kent/.cpanm/work/1488218060.1141/Getopt-Lucid-1.07/blib/arch /home/kent/.cpanm/work/1488218060.1141/Getopt-Lucid-1.07/blib/lib /home/kent/.cpanm/work/1488218060.1141/Getopt-Lucid-1.07/blib/arch /home/kent/.cpanm/work/1488218060.1141/Getopt-Lucid-1.07/blib/lib /home/kent/.cpanm/work/1488218060.1141/Getopt-Lucid-1.07/blib/arch /home/kent/perl5/perlbrew/perls/5.25.10-nossp-sdbm-nopmc-nodot/lib/site_perl/5.25.10/x86_64-linux /home/kent/perl5/perlbrew/perls/5.25.10-nossp-sdbm-nopmc-nodot/lib/site_perl/5.25.10 /home/kent/perl5/perlbrew/perls/5.25.10-nossp-sdbm-nopmc-nodot/lib/5.25.10/x86_64-linux /home/kent/perl5/perlbrew/perls/5.25.10-nossp-sdbm-nopmc-nodot/lib/5.25.10) at t/06-default-handling.t line 8.
BEGIN failed--compilation aborted at t/06-default-handling.t line 8.
t/06-default-handling.t ....
Dubious, test returned 2 (wstat 512, 0x200)
No subtests run
t/04-names.t ............... ok
Can't locate t/ErrorMessages.pm in @INC (you may need to install the t::ErrorMessages module) (@INC contains: /home/kent/.cpanm/work/1488218060.1141/Getopt-Lucid-1.07/blib/lib /home/kent/.cpanm/work/1488218060.1141/Getopt-Lucid-1.07/blib/arch /home/kent/.cpanm/work/1488218060.1141/Getopt-Lucid-1.07/blib/lib /home/kent/.cpanm/work/1488218060.1141/Getopt-Lucid-1.07/blib/arch /home/kent/.cpanm/work/1488218060.1141/Getopt-Lucid-1.07/blib/lib /home/kent/.cpanm/work/1488218060.1141/Getopt-Lucid-1.07/blib/arch /home/kent/.cpanm/work/1488218060.1141/Getopt-Lucid-1.07/blib/lib /home/kent/.cpanm/work/1488218060.1141/Getopt-Lucid-1.07/blib/arch /home/kent/.cpanm/work/1488218060.1141/Getopt-Lucid-1.07/blib/lib /home/kent/.cpanm/work/1488218060.1141/Getopt-Lucid-1.07/blib/arch /home/kent/.cpanm/work/1488218060.1141/Getopt-Lucid-1.07/blib/lib /home/kent/.cpanm/work/1488218060.1141/Getopt-Lucid-1.07/blib/arch /home/kent/.cpanm/work/1488218060.1141/Getopt-Lucid-1.07/blib/lib /home/kent/.cpanm/work/1488218060.1141/Getopt-Lucid-1.07/blib/arch /home/kent/.cpanm/work/1488218060.1141/Getopt-Lucid-1.07/blib/lib /home/kent/.cpanm/work/1488218060.1141/Getopt-Lucid-1.07/blib/arch /home/kent/.cpanm/work/1488218060.1141/Getopt-Lucid-1.07/blib/lib /home/kent/.cpanm/work/1488218060.1141/Getopt-Lucid-1.07/blib/arch /home/kent/perl5/perlbrew/perls/5.25.10-nossp-sdbm-nopmc-nodot/lib/site_perl/5.25.10/x86_64-linux /home/kent/perl5/perlbrew/perls/5.25.10-nossp-sdbm-nopmc-nodot/lib/site_perl/5.25.10 /home/kent/perl5/perlbrew/perls/5.25.10-nossp-sdbm-nopmc-nodot/lib/5.25.10/x86_64-linux /home/kent/perl5/perlbrew/perls/5.25.10-nossp-sdbm-nopmc-nodot/lib/5.25.10) at t/07-magic-names.t line 8.
BEGIN failed--compilation aborted at t/07-magic-names.t line 8.
t/07-magic-names.t .........
Dubious, test returned 2 (wstat 512, 0x200)
No subtests run
Can't locate t/ErrorMessages.pm in @INC (you may need to install the t::ErrorMessages module) (@INC contains: /home/kent/.cpanm/work/1488218060.1141/Getopt-Lucid-1.07/blib/lib /home/kent/.cpanm/work/1488218060.1141/Getopt-Lucid-1.07/blib/arch /home/kent/.cpanm/work/1488218060.1141/Getopt-Lucid-1.07/blib/lib /home/kent/.cpanm/work/1488218060.1141/Getopt-Lucid-1.07/blib/arch /home/kent/.cpanm/work/1488218060.1141/Getopt-Lucid-1.07/blib/lib /home/kent/.cpanm/work/1488218060.1141/Getopt-Lucid-1.07/blib/arch /home/kent/.cpanm/work/1488218060.1141/Getopt-Lucid-1.07/blib/lib /home/kent/.cpanm/work/1488218060.1141/Getopt-Lucid-1.07/blib/arch /home/kent/.cpanm/work/1488218060.1141/Getopt-Lucid-1.07/blib/lib /home/kent/.cpanm/work/1488218060.1141/Getopt-Lucid-1.07/blib/arch /home/kent/.cpanm/work/1488218060.1141/Getopt-Lucid-1.07/blib/lib /home/kent/.cpanm/work/1488218060.1141/Getopt-Lucid-1.07/blib/arch /home/kent/.cpanm/work/1488218060.1141/Getopt-Lucid-1.07/blib/lib /home/kent/.cpanm/work/1488218060.1141/Getopt-Lucid-1.07/blib/arch /home/kent/.cpanm/work/1488218060.1141/Getopt-Lucid-1.07/blib/lib /home/kent/.cpanm/work/1488218060.1141/Getopt-Lucid-1.07/blib/arch /home/kent/.cpanm/work/1488218060.1141/Getopt-Lucid-1.07/blib/lib /home/kent/.cpanm/work/1488218060.1141/Getopt-Lucid-1.07/blib/arch /home/kent/.cpanm/work/1488218060.1141/Getopt-Lucid-1.07/blib/lib /home/kent/.cpanm/work/1488218060.1141/Getopt-Lucid-1.07/blib/arch /home/kent/perl5/perlbrew/perls/5.25.10-nossp-sdbm-nopmc-nodot/lib/site_perl/5.25.10/x86_64-linux /home/kent/perl5/perlbrew/perls/5.25.10-nossp-sdbm-nopmc-nodot/lib/site_perl/5.25.10 /home/kent/perl5/perlbrew/perls/5.25.10-nossp-sdbm-nopmc-nodot/lib/5.25.10/x86_64-linux /home/kent/perl5/perlbrew/perls/5.25.10-nossp-sdbm-nopmc-nodot/lib/5.25.10) at t/08-strict-names.t line 11.
BEGIN failed--compilation aborted at t/08-strict-names.t line 11.
t/08-strict-names.t ........
Dubious, test returned 2 (wstat 512, 0x200)
No subtests run
Can't locate t/ErrorMessages.pm in @INC (you may need to install the t::ErrorMessages module) (@INC contains: /home/kent/.cpanm/work/1488218060.1141/Getopt-Lucid-1.07/blib/lib /home/kent/.cpanm/work/1488218060.1141/Getopt-Lucid-1.07/blib/arch /home/kent/.cpanm/work/1488218060.1141/Getopt-Lucid-1.07/blib/lib /home/kent/.cpanm/work/1488218060.1141/Getopt-Lucid-1.07/blib/arch /home/kent/.cpanm/work/1488218060.1141/Getopt-Lucid-1.07/blib/lib /home/kent/.cpanm/work/1488218060.1141/Getopt-Lucid-1.07/blib/arch /home/kent/perl5/perlbrew/perls/5.25.10-nossp-sdbm-nopmc-nodot/lib/site_perl/5.25.10/x86_64-linux /home/kent/perl5/perlbrew/perls/5.25.10-nossp-sdbm-nopmc-nodot/lib/site_perl/5.25.10 /home/kent/perl5/perlbrew/perls/5.25.10-nossp-sdbm-nopmc-nodot/lib/5.25.10/x86_64-linux /home/kent/perl5/perlbrew/perls/5.25.10-nossp-sdbm-nopmc-nodot/lib/5.25.10) at t/10-default-validation.t line 8.
BEGIN failed--compilation aborted at t/10-default-validation.t line 8.
t/10-default-validation.t ..
Dubious, test returned 2 (wstat 512, 0x200)
No subtests run
#
# Versions for all modules listed in MYMETA.json (including optional ones):
#
# === Configure Requires ===
#
# Module Want Have
# ------------------- ---- ----
# ExtUtils::MakeMaker 6.17 7.24
#
# === Build Requires ===
#
# Module Want Have
# ------------------- ---- ----
# ExtUtils::MakeMaker any 7.24
#
# === Test Requires ===
#
# Module Want Have
# -------------------------- ---- --------
# Data::Dumper any 2.167
# Exception::Class::TryCatch 1.10 1.13
# ExtUtils::MakeMaker any 7.24
# File::Spec any 3.66
# Test::More 0.62 1.302073
# vars any 1.03
#
# === Test Recommends ===
#
# Module Want Have
# ---------- -------- --------
# CPAN::Meta 2.120900 2.150010
#
# === Runtime Requires ===
#
# Module Want Have
# ---------------- ---- ----
# Carp any 1.42
# Exception::Class 1.23 1.42
# Exporter any 5.72
# Storable 2.16 2.62
# strict any 1.11
# warnings any 1.37
#
t/00-report-prereqs.t ...... ok
Test Summary Report
-------------------
t/02-getopt.t (Wstat: 512 Tests: 0 Failed: 0)
Non-zero exit status: 2
Parse errors: No plan found in TAP output
t/09-negation.t (Wstat: 512 Tests: 0 Failed: 0)
Non-zero exit status: 2
Parse errors: No plan found in TAP output
t/06-default-handling.t (Wstat: 512 Tests: 0 Failed: 0)
Non-zero exit status: 2
Parse errors: No plan found in TAP output
t/07-magic-names.t (Wstat: 512 Tests: 0 Failed: 0)
Non-zero exit status: 2
Parse errors: No plan found in TAP output
t/08-strict-names.t (Wstat: 512 Tests: 0 Failed: 0)
Non-zero exit status: 2
Parse errors: No plan found in TAP output
t/10-default-validation.t (Wstat: 512 Tests: 0 Failed: 0)
Non-zero exit status: 2
Parse errors: No plan found in TAP output
Files=12, Tests=31, 1 wallclock secs ( 0.05 usr 0.02 sys + 1.34 cusr 0.27 csys = 1.68 CPU)
Thank for you for an outstanding module.
First, a minor usage issue
[jamesb]$ ./cmd -r arg
Invalid argument: -r[jamesb]$
Note the lack of a newline for "invalid argument". Not friendly on a command line.
Second, I have this code:
use Getopt::Lucid qw<:all>;
my @options = qw<residence status>;
my @opt_spec = map Param(join '|', $_, substr $_, 0, 1), @options;
my $opt = Getopt::Lucid->getopt(\@opt_spec, {strict => 1})->validate({requires => \@options});
#my $opt = Getopt::Lucid->getopt(\@opt_spec)->validate({requires => \@options});
Using "strict" (the uncommented case) always gets
Invalid argument: --residence, or
Invalid argument: -r
Turning off strict (just change the comment above) and everything works. What could I be doing wrong? I'm using perl 5.16.3 with "use v5.16".
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.