nshki / chusaku

Annotate your Rails controllers with route info.
https://rubygems.org/gems/chusaku
MIT License
87 stars 4 forks source link

Include a rake task for invoking chusaku #40

Closed G-Rath closed 6 months ago

G-Rath commented 6 months ago

It would be nice if we had a rake task that could be used to invoke chusaku so that it could be easily integrated with rake-based workflows i.e. our codebases use both chusaku and annotate_models, so I'd like to create a general dev:annotate task that invokes both.

Technically I should be able to call chusaku programmatically but that would require understanding more of the internal classes than I'd like (and in every application!), and overall this feels like something reasonable for the gem to carry.

For reference, this is the rake tasks provided by annotate_models: https://github.com/ctran/annotate_models/blob/develop/lib/tasks/annotate_models.rake

nshki commented 6 months ago

Thanks for the suggestion! I agree, this would be a nice addition for Rake-based workflows and seems reasonable for the gem to ship with out of the box. I'll see if I can put some time toward this in the coming days.

nshki commented 6 months ago

I noticed in Annotate's gem they use environment variables to pass arguments to their Rake task. Is that a pattern that's preferred for Rake-based workflows?

e.g.

DRY_RUN=1 VERBOSE=1 bin/rake chusaku

I suppose that's a bit easier than having to do something like:

bin/rake chusaku[true, true, "some string"]

EDIT: After doing a bit more reading, I realized that we can continue to leverage OptionParser which we're already using for CLI arguments on the Rake side of things. I'll design the API such that we'll be passing in the same flags as such:

bin/rake chusaku -- --dry-run --verbose
nshki commented 6 months ago

@G-Rath would you mind taking a look at #41 for me to see if this satisfies what you're looking for?