ManageIQ / ManageIQ/optimist

Problem with short operations + underscores

Open
#37 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug help wanted
Dominant language
Ruby
Stars
259
Forks
35
PR merge metrics
No merged PRs in 30d

Description

Given:

```
parser = Trollop::Parser.new do
opt :silent, %q{Causes the script to not ask any questions, instead all questions turn into email + abort; used by cron}, :short => 's'
opt :region, %q{Causes the script only work on the listed region}, :short => 'r', :type => String
opt :noinst, %q{Causes the script to skip the checking of all instances}, :short => 'i'
end
```

Running it with -i gives us:

```
{:silent=>false,
:region=>nil,
:noinst=>true,
:help=>false,
:noinst_given=>true}
```

However, given:

```
parser = Trollop::Parser.new do
opt :silent, %q{Causes the script to not ask any questions, instead all questions turn into email + abort; used by cron}, :short => 's'
opt :region, %q{Causes the script only work on the listed region}, :short => 'r', :type => String
opt :no_instances, %q{Causes the script to skip the checking of all instances}, :short => 'i'
end
```

which is what I had originally, running it with -i gives:

```
{:silent=>false,
:region=>nil,
:no_instances=>false,
:help=>false,
:no_instances_given=>true}
```

which strikes me as wrong.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the two Trollop::Parser.new examples using the opt declarations and the -i argument. Trace how short options map to underscored option names, then verify that the corrected behavior sets no_instances to true and preserves the corresponding _given value.

Written by the indexing model from the issue text.

Assessment

Tech stack
ruby
Domain
cli
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.