Skip to content

Instantly share code, notes, and snippets.

@nikushi
Created March 4, 2013 14:44
Show Gist options
  • Save nikushi/5082683 to your computer and use it in GitHub Desktop.
Save nikushi/5082683 to your computer and use it in GitHub Desktop.
Thor example
# 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