Skip to content

Instantly share code, notes, and snippets.

@cu39
Last active August 29, 2015 13:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cu39/8687934 to your computer and use it in GitHub Desktop.
Save cu39/8687934 to your computer and use it in GitHub Desktop.
Thor executable and tasks in separate file(s).
# coding: utf-8
class Top < Thor
include Thor::Actions
class << self
def baz
puts 'baz'
end
end
module Util
def myputs(arg)
say arg, :red
end
end
end
#!/usr/bin/env ruby
# coding: utf-8
require 'thor'
require 'thor/runner'
Thor::Util.load_thorfile('./common.thor')
$thor_runner = true
Thor::Runner.start
# give this file +x permission:
# chmod +x exe
# coding: utf-8
class Top < Thor
desc "bar", "top:bar's description"
def bar
p self.class
Top::baz
end
class Foo < Thor
include Top::Util
namespace :foo
desc "bar", "foo:bar's description"
def bar(arg)
p self.class
Top::baz
myputs(arg)
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment