diff options
author | Lee Jarvis <leejarvis@fastmail.com> | 2017-08-08 15:51:26 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-08-08 15:51:26 +0100 |
commit | 4da7b30974c145debe689777dfe7eea566d354ed (patch) | |
tree | 142c0571102f1c1314910958c69f785b7c504ed0 | |
parent | bdd21e885e577ed42459c9afe185ede8e9d25fde (diff) | |
parent | e52f389dc2ee7f5988b6abfb20651f9edd6b7a26 (diff) | |
download | slop-4da7b30974c145debe689777dfe7eea566d354ed.tar.gz |
Merge pull request #214 from TomCrypto/master
Fix bug preventing '--' being passed as the first argument.
-rw-r--r-- | lib/slop/parser.rb | 1 | ||||
-rw-r--r-- | test/error_test.rb | 6 |
2 files changed, 7 insertions, 0 deletions
diff --git a/lib/slop/parser.rb b/lib/slop/parser.rb index 7d8ad46..3cba82b 100644 --- a/lib/slop/parser.rb +++ b/lib/slop/parser.rb @@ -148,6 +148,7 @@ module Slop def partition(strings) if strings.include?("--") partition_idx = strings.index("--") + return [[], strings[1..-1]] if partition_idx.zero? [strings[0..partition_idx-1], strings[partition_idx+1..-1]] else [strings, []] diff --git a/test/error_test.rb b/test/error_test.rb index 848e2d5..2f7730b 100644 --- a/test/error_test.rb +++ b/test/error_test.rb @@ -21,6 +21,12 @@ describe Slop::MissingArgument do opts.string "-n", "--name" opts.parse %w(--name) end + + it "does not raise if '--' appears as the first argument" do + opts = Slop::Options.new + opts.string "-n", "--name" + opts.parse %w(-- --name) + end end describe Slop::UnknownOption do |