Giter VIP home page Giter VIP logo

getopt-kingpin's People

Contributors

ehime-iyokan avatar pvgoran avatar sago35 avatar syohex avatar tobyink avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

getopt-kingpin's Issues

Error messages should end with a newline

Normally, human-readable command output is newline-terminated. Kingpin's error messages are not. Popular shells don't take it very well: bash shows its prompt after the non-terminated line, and zsh (version 5.4.2 in Nixos) somehow "eats" the non-terminated line, thus hiding the error message completely.

Hash-typed flags

For arguments like this:

myscript.pl command --define os=linux --define arch=amd64

And $flag->values should return:

{
  "os" => "linux",
  "arch" => "amb64",
}

Getopt::Long supports this. If you think this would be a useful feature, I would be happy to send you a patch.

Encoding problem in default value

In japanese windows, file paths encoding is cp932.
When you want to use file with default value,

  1. Default value with cp932 encoding is works good for Path::Tiny, but help() can't read.
  2. with flagged utf8, help() can read. But Path::Tiny does not work.

`parse` should really take an arrayref

$kingpin->parse parses @ARGV but $kingpin->parse(@args) parses @args... except if @args is an empty array, in which case it parses @ARGV even though that's not what you asked it to do.

If parse took an arrayref, then it would be easier for parse to tell if you wanted it to parse your array or parse @ARGV.

$kingpin->parse( \@args ); # parse @args 
$kingpin->parse( [] );     # parse an empty array
$kingpin->parse;           # parse @ARGV 

But Getopt::Kingpin has already existed for four years, so it is probably too late to change the behaviour of parse. Instead I think a separate method called parse_array should be added and parse should be... not quite deprecated but discouraged.

Place holder in help

This is kingpin's README.md.


Place-holders in Help

The place-holder value for a flag is the value used in the help to describe
the value of a non-boolean flag.

The value provided to PlaceHolder() is used if provided, then the value
provided by Default() if provided, then finally the capitalised flag name is
used.

Here are some examples of flags with various permutations:

--name=NAME           // Flag(...).String()
--name="Harry"        // Flag(...).Default("Harry").String()
--name=FULL-NAME      // flag(...).PlaceHolder("FULL-NAME").Default("Harry").String()

Lazy defaults

For me, it would be useful if Getopt::Kingpin supported "lazy" defaults like Moo/Moose attributes do. So, for example:

$command->flag("email", "Email address")->default(sub { ... })->string;

Looking up the email address might be an expensive operation; it might need a database lookup for example. The coderef would only be called if the user does not provide --email=something on the command line.

It would allow things like:

$command->flag("email", "Email address")->default(sub {
  print STDERR "Please provide an email address!\n";
  chomp( my $email = <STDIN> );
  return $email;
})->string;

I can provide a PR if you think this is a useful feature which you would be likely to accept.

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.