-
Notifications
You must be signed in to change notification settings - Fork 116
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
CLI interface should be at the object, not class, level #697
Comments
Given that the |
It used to be stateless (well, it would only change state once after parsing via the However, when repeatable options were introduced, we changed the behaviour to this: def assign_result!(option, result)
if option.repeatable && option.type == :hash
(@assigns[option.human_name] ||= {}).merge!(result) # <-uh oh! @assigns may contain leftover information from a previous invocation!
elsif option.repeatable
(@assigns[option.human_name] ||= []) << result # same issue here
else
@assigns[option.human_name] = result
end
end So instead of reassigning the value of Since we only ever expect |
Making
Can you clarify what you mean by this? |
Update: so of course after all of this investigation the fix is exactly 4 characters long A bit more research has left me with more questions than answers. Options::@default behaves strangely when
|
Fixed upstream by rails/thor#715 |
Bug report
When attempting to implement #658 (repeatable flags), our test suite would break, since flags marked repeatable would persist, even beyond the boundaries of test methods (e.g.
testB
would contain parsed options fromtestA
). Initially I thought this was an error in Thor, but on closer inspection, it appears to be an issue in the design of our CLI commands.Our CLI commands all follow a similar invocation design:
I propose changing
KLASS.from_options(options)
toKLASS.new(options)
. This gives us finer-grained control over the scope of these CLI invocations.Expected behavior: [What you expected to happen]
Actual behavior: [What actually happened]
krane_deploy("-f foo bar") -> 'filenames = ['foo', 'bar']
krane_deploy() -> "filenames = ['foo', 'bar']
Version(s) affected:
version 1 and up are affected, though currently we don't do anything that causes this behaviour to make problems for us.
Steps to Reproduce
set
repeatable: true
to any CLI arg and run the test suiteThe text was updated successfully, but these errors were encountered: