Last active
August 29, 2015 13:55
-
-
Save cu39/8687934 to your computer and use it in GitHub Desktop.
Thor executable and tasks in separate file(s).
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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