Skip to content

Making An Executable

derickbailey edited this page Apr 14, 2011 · 4 revisions

You may want to make a script as an executable command. Let the line #{your thor class name}.start be the end of the script.

Example: mythorcommand.rb

#!/usr/bin/env ruby
require "rubygems" # ruby1.9 doesn't "require" it though
require "thor"
class MyThorCommand < Thor
  desc "foo", "Prints foo"
  def foo
    puts "foo"
  end
end
MyThorCommand.start

Then make the script executable:

chmod a+x mythorcommand.rb

Now you can type:

./mythorcommand.rb foo
Clone this wiki locally