gito
gito copied to clipboard
flag ordering shouldn't matter
> gito -e cesarferreira/gito
~/.gem/ruby/2.4.1/gems/gito-0.4.13/lib/gito/project.rb:36:in `destination': undefined method `gsub' for nil:NilClass (NoMethodError)
from ~/.gem/ruby/2.4.1/gems/gito-0.4.13/lib/gito/project.rb:12:in `initialize'
from ~/.gem/ruby/2.4.1/gems/gito-0.4.13/lib/gito.rb:107:in `new'
from ~/.gem/ruby/2.4.1/gems/gito-0.4.13/lib/gito.rb:107:in `call'
from ~/.gem/ruby/2.4.1/gems/gito-0.4.13/bin/gito:6:in `<top (required)>'
from ~/.gem/ruby/2.4.1/bin/gito:22:in `load'
from ~/.gem/ruby/2.4.1/bin/gito:22:in `<main>'
> gito cesarferreira/gito -e
😙 Cloning [email protected]:cesarferreira/gito.git...
Likely cause - https://github.com/cesarferreira/gito/blob/master/lib/gito.rb#L15
OptParse will strip flags out already:
require 'optparse'
puts "Before: #{ARGV}"
options = {}
OptionParser.new do |opts|
opts.on('-e') { options[:editor] = true }
opts.on('-t') { options[:temp] = true }
end.parse!
puts "Options: #{options}"
puts "After: #{ARGV}"
➜ sandbox ruby optparse_test.rb -e -t myurl
Before: ["-e", "-t", "myurl"]
Options: {:editor=>true, :temp=>true}
After: ["myurl"]
➜ sandbox ruby optparse_test.rb -e myurl -t
Before: ["-e", "myurl", "-t"]
Options: {:editor=>true, :temp=>true}
After: ["myurl"]
➜ sandbox ruby optparse_test.rb myurl -t -e
Before: ["myurl", "-t", "-e"]
Options: {:temp=>true, :editor=>true}
After: ["myurl"]