Shopify/packwerk

Refactor cli.rb to be smaller and testable

wildmaples opened this issue · 1 comments

As @doodzik mentioned in https://github.com/Shopify/packwerk/pull/61/files#r517545831, we should look into refactoring cli.rb as it is growing to be a large class.

We should move all of the different commands we have in to compositional objects, so we can just do something like command.run. Breaking this class up would make it easier to have unit tests.

I would also be curious to see how RuboCop implements their Cli class.

@cindygshopify and I did some pairing on this the other day, and I thought we found a nice separation between the CLI and Command class. I think we can apply the same pattern for all the commands. Here is the implementation: https://github.com/Shopify/packwerk/pull/61/files#diff-66788d8e2cafe199807e9963fd538243bcdd6ab0ea3203f07464cb93109e78c0R12-R63

@wildmaples thanks for opening the issue, so we don't forget and can link back to this issue :)