[Feature Idea] Adding a Generator for Thor Commands

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

[Feature Idea] Adding a Generator for Thor Commands

Joshua Klina
While Rails has great support for adding Rake tasks there is currently no information on how to add Thor commands, despite Thor playing an active role internally. I find Thor commands to be better for handling more sophisticated interaction from the user and they're great for testing. There already seems to be solid conventions in place for Rails/Thor commands for either engines or applications however, this is currently undocumented.

I just wrote an article describing how an app or engine author can add their own namespaced Commands here: http://www.joshklina.com/posts/adding-thor-commands-to-rails

I'd be happy to create a patch that adds a Command generator and write up documentation if you folks would be interested.

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/rubyonrails-core.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: [Feature Idea] Adding a Generator for Thor Commands

Kasper Timm Hansen
Great blog post! 👏

I think the answer you’re looking for is: yet. We want apps to be able to write full fledged commands for all the reasons you mention, we just haven’t finished it up… yet.

That’s why there’s no documentation and the reason for the rough edge you mention at the end of your post.

Here’s where you and others can help now:

- Better load paths and loading: helps with the issue you identified. Must work for our internal commands as well as apps.
- Command dependencies: attaching a command to run after e.g. db:migrate (so we can move our Rake tasks to Rails commands, plus apps can write commands that hook in after db:migrate etc.)
- Making commands conductable: finally fulfilling the 13+ year dream of https://github.com/rails/conductor come true. Should be great for people new to Rails too!

Later, we’ll need the command generator, like you mentioned, and proper documentation.


Again, appreciate the write up! Since you’re already eager to make this work in your apps, you’d be a good fit to help out here.

So: looking forward to your issues/pull requests ❤️

Den 7. apr. 2017 kl. 00.22 skrev Joshua Klina <[hidden email]>:

While Rails has great support for adding Rake tasks there is currently no information on how to add Thor commands, despite Thor playing an active role internally. I find Thor commands to be better for handling more sophisticated interaction from the user and they're great for testing. There already seems to be solid conventions in place for Rails/Thor commands for either engines or applications however, this is currently undocumented.

I just wrote an article describing how an app or engine author can add their own namespaced Commands here: http://www.joshklina.com/posts/adding-thor-commands-to-rails

I'd be happy to create a patch that adds a Command generator and write up documentation if you folks would be interested.

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/rubyonrails-core.
For more options, visit https://groups.google.com/d/optout.

--
Kasper

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/rubyonrails-core.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: [Feature Idea] Adding a Generator for Thor Commands

Joshua Klina
In reply to this post by Joshua Klina
Thanks for the roadmap! I'll go ahead and see if I can start chipping away at this!

Cheers,
Josh

On Thursday, April 6, 2017 at 6:39:40 PM UTC-6, Joshua Klina wrote:
While Rails has great support for adding Rake tasks there is currently no information on how to add Thor commands, despite Thor playing an active role internally. I find Thor commands to be better for handling more sophisticated interaction from the user and they're great for testing. There already seems to be solid conventions in place for Rails/Thor commands for either engines or applications however, this is currently undocumented.

I just wrote an article describing how an app or engine author can add their own namespaced Commands here: <a href="http://www.joshklina.com/posts/adding-thor-commands-to-rails" target="_blank" rel="nofollow" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fwww.joshklina.com%2Fposts%2Fadding-thor-commands-to-rails\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGctdiD0ZJ90LDapE30HtD06RtLnQ&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fwww.joshklina.com%2Fposts%2Fadding-thor-commands-to-rails\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGctdiD0ZJ90LDapE30HtD06RtLnQ&#39;;return true;">http://www.joshklina.com/posts/adding-thor-commands-to-rails

I'd be happy to create a patch that adds a Command generator and write up documentation if you folks would be interested.

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/rubyonrails-core.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: [Feature Idea] Adding a Generator for Thor Commands

Kasper Timm Hansen
Happy to hear it!

Den 10. apr. 2017 kl. 20.14 skrev Joshua Klina <[hidden email]>:

Thanks for the roadmap! I'll go ahead and see if I can start chipping away at this!

Cheers,
Josh

On Thursday, April 6, 2017 at 6:39:40 PM UTC-6, Joshua Klina wrote:
While Rails has great support for adding Rake tasks there is currently no information on how to add Thor commands, despite Thor playing an active role internally. I find Thor commands to be better for handling more sophisticated interaction from the user and they're great for testing. There already seems to be solid conventions in place for Rails/Thor commands for either engines or applications however, this is currently undocumented.

I just wrote an article describing how an app or engine author can add their own namespaced Commands here: <a href="http://www.joshklina.com/posts/adding-thor-commands-to-rails" target="_blank" rel="nofollow" onmousedown="this.href='http://www.google.com/url?q\x3dhttp%3A%2F%2Fwww.joshklina.com%2Fposts%2Fadding-thor-commands-to-rails\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGctdiD0ZJ90LDapE30HtD06RtLnQ';return true;" onclick="this.href='http://www.google.com/url?q\x3dhttp%3A%2F%2Fwww.joshklina.com%2Fposts%2Fadding-thor-commands-to-rails\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGctdiD0ZJ90LDapE30HtD06RtLnQ';return true;" class="">http://www.joshklina.com/posts/adding-thor-commands-to-rails

I'd be happy to create a patch that adds a Command generator and write up documentation if you folks would be interested.

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/rubyonrails-core.
For more options, visit https://groups.google.com/d/optout.

--
Kasper

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/rubyonrails-core.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: [Feature Idea] Adding a Generator for Thor Commands

Joshua Klina
In reply to this post by Joshua Klina
Hi Kasper,

I started diving into this and added a way to incorporate a Rails app into the load path for commands. The Railties test suite seems to pass, but I wanted to get some feedback before submitting a pull request.

https://github.com/rails/rails/compare/master...jklina:thor_load_paths

Thanks!

On Thursday, April 6, 2017 at 6:39:40 PM UTC-6, Joshua Klina wrote:
While Rails has great support for adding Rake tasks there is currently no information on how to add Thor commands, despite Thor playing an active role internally. I find Thor commands to be better for handling more sophisticated interaction from the user and they're great for testing. There already seems to be solid conventions in place for Rails/Thor commands for either engines or applications however, this is currently undocumented.

I just wrote an article describing how an app or engine author can add their own namespaced Commands here: <a href="http://www.joshklina.com/posts/adding-thor-commands-to-rails" target="_blank" rel="nofollow" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fwww.joshklina.com%2Fposts%2Fadding-thor-commands-to-rails\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGctdiD0ZJ90LDapE30HtD06RtLnQ&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fwww.joshklina.com%2Fposts%2Fadding-thor-commands-to-rails\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGctdiD0ZJ90LDapE30HtD06RtLnQ&#39;;return true;">http://www.joshklina.com/posts/adding-thor-commands-to-rails

I'd be happy to create a patch that adds a Command generator and write up documentation if you folks would be interested.

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/rubyonrails-core.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: [Feature Idea] Adding a Generator for Thor Commands

Kasper Timm Hansen
Pull requests are made to get feedback, so if you’ve got the code why not just open one? :D

Feel free to use "r? @kaspth" to assign it to me.

Den 14. apr. 2017 kl. 23.56 skrev Joshua Klina <[hidden email]>:

Hi Kasper,

I started diving into this and added a way to incorporate a Rails app into the load path for commands. The Railties test suite seems to pass, but I wanted to get some feedback before submitting a pull request.

https://github.com/rails/rails/compare/master...jklina:thor_load_paths

Thanks!

On Thursday, April 6, 2017 at 6:39:40 PM UTC-6, Joshua Klina wrote:
While Rails has great support for adding Rake tasks there is currently no information on how to add Thor commands, despite Thor playing an active role internally. I find Thor commands to be better for handling more sophisticated interaction from the user and they're great for testing. There already seems to be solid conventions in place for Rails/Thor commands for either engines or applications however, this is currently undocumented.

I just wrote an article describing how an app or engine author can add their own namespaced Commands here: <a href="http://www.joshklina.com/posts/adding-thor-commands-to-rails" target="_blank" rel="nofollow" onmousedown="this.href='http://www.google.com/url?q\x3dhttp%3A%2F%2Fwww.joshklina.com%2Fposts%2Fadding-thor-commands-to-rails\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGctdiD0ZJ90LDapE30HtD06RtLnQ';return true;" onclick="this.href='http://www.google.com/url?q\x3dhttp%3A%2F%2Fwww.joshklina.com%2Fposts%2Fadding-thor-commands-to-rails\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGctdiD0ZJ90LDapE30HtD06RtLnQ';return true;" class="">http://www.joshklina.com/posts/adding-thor-commands-to-rails

I'd be happy to create a patch that adds a Command generator and write up documentation if you folks would be interested.

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/rubyonrails-core.
For more options, visit https://groups.google.com/d/optout.

--
Kasper

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/rubyonrails-core.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: [Feature Idea] Adding a Generator for Thor Commands

Joshua Klina
Couldn't figure out how to assign it to you specifically, but I created the pull request here:

https://github.com/rails/rails/pull/28812

Thanks again for the help!

On Wednesday, April 19, 2017 at 12:53:31 PM UTC-6, Kasper Timm Hansen wrote:
Pull requests are made to get feedback, so if you’ve got the code why not just open one? :D

Feel free to use "r? @kaspth" to assign it to me.

Den 14. apr. 2017 kl. 23.56 skrev Joshua Klina <<a href="javascript:" target="_blank" gdf-obfuscated-mailto="RLK_Ya4eAgAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">joshua...@...>:

Hi Kasper,

I started diving into this and added a way to incorporate a Rails app into the load path for commands. The Railties test suite seems to pass, but I wanted to get some feedback before submitting a pull request.

<a href="https://github.com/rails/rails/compare/master...jklina:thor_load_paths" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fgithub.com%2Frails%2Frails%2Fcompare%2Fmaster...jklina%3Athor_load_paths\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNHI4PS-dU8AM8NP-ZTRLUEGnp9vxQ&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fgithub.com%2Frails%2Frails%2Fcompare%2Fmaster...jklina%3Athor_load_paths\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNHI4PS-dU8AM8NP-ZTRLUEGnp9vxQ&#39;;return true;">https://github.com/rails/rails/compare/master...jklina:thor_load_paths

Thanks!

On Thursday, April 6, 2017 at 6:39:40 PM UTC-6, Joshua Klina wrote:
While Rails has great support for adding Rake tasks there is currently no information on how to add Thor commands, despite Thor playing an active role internally. I find Thor commands to be better for handling more sophisticated interaction from the user and they're great for testing. There already seems to be solid conventions in place for Rails/Thor commands for either engines or applications however, this is currently undocumented.

I just wrote an article describing how an app or engine author can add their own namespaced Commands here: <a href="http://www.joshklina.com/posts/adding-thor-commands-to-rails" rel="nofollow" target="_blank" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fwww.joshklina.com%2Fposts%2Fadding-thor-commands-to-rails\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGctdiD0ZJ90LDapE30HtD06RtLnQ&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fwww.joshklina.com%2Fposts%2Fadding-thor-commands-to-rails\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGctdiD0ZJ90LDapE30HtD06RtLnQ&#39;;return true;">http://www.joshklina.com/posts/adding-thor-commands-to-rails

I'd be happy to create a patch that adds a Command generator and write up documentation if you folks would be interested.

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group.
To unsubscribe from this group and stop receiving emails from it, send an email to <a href="javascript:" target="_blank" gdf-obfuscated-mailto="RLK_Ya4eAgAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">rubyonrails-co...@googlegroups.com.
To post to this group, send email to <a href="javascript:" target="_blank" gdf-obfuscated-mailto="RLK_Ya4eAgAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">rubyonra...@googlegroups.com.
Visit this group at <a href="https://groups.google.com/group/rubyonrails-core" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://groups.google.com/group/rubyonrails-core&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/group/rubyonrails-core&#39;;return true;">https://groups.google.com/group/rubyonrails-core.
For more options, visit <a href="https://groups.google.com/d/optout" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;">https://groups.google.com/d/optout.

--
Kasper

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/rubyonrails-core.
For more options, visit https://groups.google.com/d/optout.