GithubHelp home page GithubHelp logo

dagolden / getopt-lucid Goto Github PK

View Code? Open in Web Editor NEW
10.0 4.0 7.0 205 KB

(Perl) Clear, readable syntax for command line processing

Home Page: http://search.cpan.org/dist/Getopt-Lucid

Perl 100.00%

getopt-lucid's Introduction

HOW TO CONTRIBUTE

Thank you for considering contributing to this distribution. This file contains instructions that will help you work with the source code.

The distribution is managed with Dist::Zilla. This means that many of the usual files you might expect are not in the repository, but are generated at release time, as is much of the documentation. Some generated files are kept in the repository as a convenience (e.g. Makefile.PL or cpanfile).

Generally, you do not need Dist::Zilla to contribute patches. You do need Dist::Zilla to create a tarball. See below for guidance.

Getting dependencies

If you have App::cpanminus 1.6 or later installed, you can use cpanm to satisfy dependencies like this:

$ cpanm --installdeps .

Otherwise, look for either a Makefile.PL or cpanfile file for a list of dependencies to satisfy.

Running tests

You can run tests directly using the prove tool:

$ prove -l
$ prove -lv t/some_test_file.t

For most of my distributions, prove is entirely sufficient for you to test any patches you have. I use prove for 99% of my testing during development.

Code style and tidying

Please try to match any existing coding style. If there is a .perltidyrc file, please install Perl::Tidy and use perltidy before submitting patches.

If there is a tidyall.ini file, you can also install Code::TidyAll and run tidyall on a file or tidyall -a to tidy all files.

Patching documentation

Much of the documentation Pod is generated at release time. Some is generated boilerplate; other documentation is built from pseudo-POD directives in the source like C<=method> or C<=func>.

If you would like to submit a documentation edit, please limit yourself to the documentation you see.

If you see typos or documentation issues in the generated docs, please email or open a bug ticket instead of patching.

Where to send patches and pull requests

If you found this distribution on Github, sending a pull-request is the best way to contribute.

If a pull-request isn't possible, a bug ticket with a patch file is the next best option.

As a last resort, an email to the author(s) is acceptable.

Installing and using Dist::Zilla

Dist::Zilla is not required for contributing, but if you'd like to learn more, this section will get you up to speed.

Dist::Zilla is a very powerful authoring tool, optimized for maintaining a large number of distributions with a high degree of automation, but it has a large dependency chain, a bit of a learning curve and requires a number of author-specific plugins.

To install it from CPAN, I recommend one of the following approaches for the quickest installation:

# using CPAN.pm, but bypassing non-functional pod tests
$ cpan TAP::Harness::Restricted
$ PERL_MM_USE_DEFAULT=1 HARNESS_CLASS=TAP::Harness::Restricted cpan Dist::Zilla

# using cpanm, bypassing *all* tests
$ cpanm -n Dist::Zilla

In either case, it's probably going to take about 10 minutes. Go for a walk, go get a cup of your favorite beverage, take a bathroom break, or whatever. When you get back, Dist::Zilla should be ready for you.

Then you need to install any plugins specific to this distribution:

$ cpan `dzil authordeps`
$ dzil authordeps | cpanm

Once installed, here are some dzil commands you might try:

$ dzil build
$ dzil test
$ dzil xtest

You can learn more about Dist::Zilla at http://dzil.org/

getopt-lucid's People

Contributors

bigpresh avatar cxw42 avatar jkeenan avatar patch avatar thilp avatar xdg avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

getopt-lucid's Issues

questions/issues re: Getopt::Lucid

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".

Negation and strict processing are confusing

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.)

Workaround

Switch('--rawdump|rawdump')->default(1),

Than the negation switch --no-rawdump works as expected.

TODO

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.

'needs' is too specific; we need a more flexible test

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/),
];

Fails tests without '.' in @INC

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.