Ruby on Rails
Thursday, September 10, 2015
Thank you.
If I move my thor task to lib/thor directory, how can I use it? Also by rails runner? Then there has the same trouble.
Your second method is good for me. Now I am using Rails 4, I tried to make a thor script file under bin/ likes bin/thor.
But how to run the file under lib/tasks/my_cli.rb in that script?
On Friday, September 11, 2015 at 11:02:05 AM UTC+9, tamouse wrote:
-- If I move my thor task to lib/thor directory, how can I use it? Also by rails runner? Then there has the same trouble.
Your second method is good for me. Now I am using Rails 4, I tried to make a thor script file under bin/ likes bin/thor.
But how to run the file under lib/tasks/my_cli.rb in that script?
On Friday, September 11, 2015 at 11:02:05 AM UTC+9, tamouse wrote:
the lib/tasks directory is for Rake tasks, and anything in it that ends in .rake or .rb will be loaded up with the environment.i suggest putting them in lib/thor/, or if you make them standalone thor scripts you can put them in scripts/On Thu, Sep 10, 2015 at 4:52 AM, <seiky...@voyagegroup.com> wrote:--Thor is a toolkit for building powerful command-line interfaces.It always been used for single command line. If I want to use it in a rails project, for example:lib/tasks/my_cli.rbrequire "thor"
class MyCLI < Thor
desc "hello NAME", "say hello to NAME"
def hello(name)
puts "Hello #{name}"
end
endWhere to put the `MyCLI.start(ARGV)`?If I put it under that file(`lib/tasks/my_cli.rb`), when I run my rspec test, it will show me the command message:Commands:
rspec help [COMMAND] # Describe available commands or one specific command
rspec hello NAME # say hello to NAMEI don't want to see it in my `bundle exec rspec`, so I moved the `MyCLI.start(ARGV)` to `bin/rails`. It looks well. But after I do this:$ ./bin/rails s -b 0.0.0.0
$ [CTRL+C]I saw this message:=> Booting Thin
=> Rails 4.2.0 application starting in development on http://0.0.0.0:3000
=> Run `rails server -h` for more startup options
=> Ctrl-C to shutdown server
Thin web server (v1.6.3 codename Protein Powder)
Maximum connections set to 1024
Listening on 0.0.0.0:3000, CTRL+C to stop
^CStopping ...
Exiting
Could not find command "_b".What does it mean:Could not find command "_b".So, I don't know a best practice about how to use thor in a rails project.
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-ta...@googlegroups.com .
To post to this group, send email to rubyonra...@googlegroups.com .
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/ .cf41f08a-e19a-4c3d-9bd0- e7d4913a9c4d%40googlegroups. com
For more options, visit https://groups.google.com/d/optout .
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/103aede1-4102-486a-8610-faa3fa3e1415%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment