Skip to content

Instantly share code, notes, and snippets.

@shiraji
Last active December 17, 2015 02:08
Show Gist options
  • Save shiraji/5533075 to your computer and use it in GitHub Desktop.
Save shiraji/5533075 to your computer and use it in GitHub Desktop.
#! /usr/local/bin/ruby
require 'thor'
class Test < Thor
class_option :help, :type => :boolean, :aliases => '-h', :desc => 'Thor test'
default_task :execute
desc "execute [OPTION]", "Test execute"
option :production, :type => :boolean, :aliases => '-p', :desc => "Run production DB server"
option :number, :type => :numeric, :aliases => '-n', :default => 3, :desc => "test number"
def execute
# DBオプション
if options[:production] then
@mode = 'PRODUCTION'
else
@mode = 'DEVELOPMENT'
end
puts @mode
puts options['number']
end
end
Test.start
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment