Skip to content

Commit

Permalink
Merge pull request #691 from timothysmith0609/looser_flag_detection
Browse files Browse the repository at this point in the history
 🌈 More accurate Arguments#current_is_value? check
  • Loading branch information
rafaelfranca authored Nov 22, 2019
2 parents afdcf1c + 873da2a commit 630bbee
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/thor/parser/arguments.rb
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ def unshift(arg)
end

def current_is_value?
peek && peek.to_s !~ /^-/
peek && peek.to_s !~ /^-{1,2}\S+/
end

# Runs through the argument array getting strings that contains ":" and
Expand Down
6 changes: 6 additions & 0 deletions spec/parser/arguments_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,12 @@ def parse(*args)
expect(parse("product", "title", "age")["array"]).to eq(%w(title age))
end

it "accepts - as an array argument" do
create :array => nil
expect(parse("-")["array"]).to eq(%w(-))
expect(parse("-", "title", "-")["array"]).to eq(%w(- title -))
end

describe "with no inputs" do
it "and no arguments returns an empty hash" do
create
Expand Down

0 comments on commit 630bbee

Please sign in to comment.