ManageIQ / ManageIQ/optimist

Using '=' to choose arguments breaks multi-line inputs for type 'string'

Open
#138 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

My code needs to input multi-line strings as a single value.
Entirety of the test code I created to test this issue:

require 'optimist'
opts = Optimist::options do
  opt :foo, 'foobar', short:none, type: :string
end
puts "foo is #{opts[:foo]}"

Command that works:

ruby rubyfile.rb --foo "bar
baz
qux" 

Output of command that works:

foo is bar
baz
qux

Command that produces error:

ruby rubyfile.rb --foo="bar
baz
qux" 

Output of command that produces error:

foo is bar

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 running the two Ruby command examples from the issue against the provided Optimist option definition and compare how the value is parsed. Trace the handling of the --foo and --foo= forms; done means the equals form preserves all three lines of the multiline string, matching the space-separated form.

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
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.