Skip to content

Conversation

evgeni
Copy link
Contributor

@evgeni evgeni commented Oct 3, 2014

Instead of writing foo|f=s you can also write foo|f:s for a GetOpt::Long
option spec [1], thus making the argument optional.

The current implementation of _spec_to_help will wrongly render this as two
long options:

--dirport, --d:9030
   directory port

instead of a short and a long one:

-d, --dirport=INTEGER
   directory port

This commit fixes the the parsing of the spec, detection of the type and adds
tests for a few common cases this could be used in.

[1] http://perldoc.perl.org/Getopt/Long.html#Summary-of-Option-Specifications

evgeni added 2 commits October 3, 2014 21:11
Instead of writing `foo|f=s` you can also write `foo|f:s` for a GetOpt::Long
option spec [1], thus making the argument optional.

The current implementation of `_spec_to_help` will wrongly render this as two
long options:

    --dirport, --d:9030
       directory port

instead of a short and a long one:

    -d, --dirport=INTEGER
       directory port

This commit fixes the the parsing of the spec, detection of the type and adds
tests for a few common cases this could be used in.

[1] http://perldoc.perl.org/Getopt/Long.html#Summary-of-Option-Specifications
sni added a commit that referenced this pull request Dec 28, 2014
GetOpt::Long optional arguments using a colon instead of an equal sign
@sni sni merged commit 769c840 into monitoring-plugins:master Dec 28, 2014
@sni
Copy link
Contributor

sni commented Dec 28, 2014

thanks for you patch and sorry for the delay.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants