Created
March 4, 2013 14:44
-
-
Save nikushi/5082683 to your computer and use it in GitHub Desktop.
Thor example
This file contains hidden or 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
# encoding: utf-8 | |
require 'thor' | |
class App < Thor | |
desc 'hello', "Let's say hello!" | |
def hello | |
puts 'Hello world!' | |
end | |
desc 'konichiwa NAME', 'say hello to NAME san in Japanese' | |
def konichiwa name | |
puts "こんにちは、#{name} さん!" | |
end | |
desc 'greet [NAME]', 'greet to people' | |
method_option :japanese, | |
:type => :boolean, | |
:aliases => '-j', | |
:desc => 'in Japanese' | |
def greet name = 'world' | |
if options[:japanese] | |
konichiwa name | |
else | |
puts "Hello #{name}" | |
end | |
end | |
end | |
App.start |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment