support positional arguments
fawaf opened this issue · comments
Felix Wong commented
e.g.
ruby foo.rb test
Lee Jarvis commented
Could you elaborate on what's broken here? Your example doesn't really help too much. Thanks!
Felix Wong commented
sorry. this is more of a feature enhancement. i don't believe there is a way to extract out the "test" argument since this gem does not support positional arguments instead of regular "-" or "--" arguments.
% ruby foo.rb test
(do something with argument "test")
hello my name is "test"
%
Lee Jarvis commented
Slop::Result
has an arguments
methods which returns the arguments sans parsed options. It looks like this:
#!/usr/bin/env ruby
require "slop"
opts = Slop.parse do |o|
o.string "--name"
end
# ruby foo.rb test --name lee example
p opts.arguments #=> ["test", "example"]
So, in your case you could simply do opts.arguments.first
Hope that helps!