-
Notifications
You must be signed in to change notification settings - Fork 71
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Slop::Options and Slop::Parser not decoupled #228
Comments
Thanks for reporting. This is interesting, and definitely unexpected behaviour. I would consider it a bug of the internal API. I suspect it's happening because o = Slop::Options.new
o.string '--something', 'give me something'
o.options.first.freeze
opts1 = Slop::Parser.new(o).parse([])
opts2 = Slop::Parser.new(o).parse(['--something', 'cool'])
#=> /lib/slop/option.rb:41:in `reset': can't modify frozen Slop::StringOption (FrozenError) Ideally we would be able to deal with this gracefully, but it may be a bit of a stretch goal, and I'm not sure it's worth spending much time on this if it's only used internally (note that |
Thanks for your quick reply! I just had a look at parser.rb and options.rb. It seems that the parsing actually happens in the class Slop::Parser
def initialize(options, **config)
@options = options.dup
@options.instance_variable_set('@options', @options.map{|o| o.dup})
@config = config
reset
end
end But I guess this is not what you meant with "graceful" :) Otherwise, a simple workaround is to regenerate the Perhaps mentioning this in the README can also help. |
Yeah, I think we might be able to create something (only slightly) nicer using |
Excellent library, I use it a lot. Thanks for sharing it!
This is not really a bug. I just didn't expect the behavior. Consider this:
It seems that now
I'm using slop 4.6.2.
The text was updated successfully, but these errors were encountered: