Skip to content

test "throw away double dash" and also fix pass_through generally #76

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Dec 30, 2024

Conversation

rjbs
Copy link
Owner

@rjbs rjbs commented Dec 30, 2024

No description provided.

rjbs added 4 commits December 30, 2024 17:03
Imagine this invocation:

  appname cmdname -a one -- -z two

Common sense (I think) would lead us to believe that when the "execute"
method on the command class for "cmdname" is called, $args would
contain:

  [ '-z', 'two' ]

...but in reality, we get the leading `--`.  That's really just meant to
be an instruction to Getopt::Long, and not an argv token.  This commit
adds a test for this case.  It also sets _getopt_conf in Test::MyCmd to
[] because without that, unknown tokens are passed along, including the
`--`.
When interpreting:

    appname   [ cmdname --xyz ]

    ^- ARG0   ^- ARGV

Getopt::Long is run against the ARGV twice: once to pluck out global
options and command name from the start, once to process the options to
that command.

The first pass must *always* be called with $Getopt::Long::pass_through
set, because that's how "cmdname" is left in place.  Because the
arguments to Getopt::Long::Configure are an ordered list of
instructions, we can just tack "pass_through" on to the end, even if it
was already in the defaults, or follows a "no_pass_through".

This change will require Getopt::Long::Descriptive 0.116, because
previous versions do not localize their changes to Getopt::Long
configuration.
@rjbs rjbs merged commit 76f64eb into main Dec 30, 2024
38 checks passed
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.

1 participant