Skip to content

CLI interface should be at the object, not class, level #697

@timothysmith0609

Description

@timothysmith0609

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 from testA). 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:

def command
  rescue_and_exit do
    KLASS.from_options(options)
end

I propose changing KLASS.from_options(options) to KLASS.new(options). This gives us finer-grained control over the scope of these CLI invocations.

Expected behavior: [What you expected to happen]

krane_deploy("-f foo bar") -> 'filenames = ['foo', 'bar']
krane_deploy() -> "filenames = []

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 suite

Metadata

Metadata

Labels

No labels
No labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions