module Github
class Repo < Thor
include Octopi
desc "create NAME", "create a new public repository"
method_option :description, :type => :string
method_option :homepage, :type => :string
method_option :private, :type => :boolean
def create(name)
authenticated do
repo_options = {:name => name}
[:description, :homepage ].each{|o| repo_options[o] = options[o] if options[o]}
repo_options[:public] = 0 if options[:private]
Repository.create(repo_options)
end
end
...
end
Running thor task
kristian-mandrups-macbook-pro:lib kristianconsult$ thor github:repo:create cool_stuff
W, [2010-04-05T15:18:50.956361 #15333] WARN -- : Using in memory store
I, [2010-04-05T15:18:57.762911 #15333] INFO -- : Failed to fetch from API - Exception: APICache::TimeoutError: Timed out when calling API (timeout 5s)
W, [2010-04-05T15:18:57.763000 #15333] WARN -- : Data not available in the cache or from API for key
/Users/kristianconsult/.rvm/gems/ruby-1.9.1-p378/gems/api_cache-0.2.0/lib/api_cache/api.rb:47:in `rescue in get': Timed out when calling API (timeout 5s) (APICache::TimeoutError)
from /Users/kristianconsult/.rvm/gems/ruby-1.9.1-p378/gems/api_cache-0.2.0/lib/api_cache/api.rb:35:in `get'
from /Users/kristianconsult/.rvm/gems/ruby-1.9.1-p378/gems/api_cache-0.2.0/lib/api_cache.rb:107:in `get'
from /Users/kristianconsult/.rvm/gems/ruby-1.9.1-p378/gems/octopi-0.2.8/lib/octopi/api.rb:178:in `submit'
from /Users/kristianconsult/.rvm/gems/ruby-1.9.1-p378/gems/octopi-0.2.8/lib/octopi/api.rb:142:in `post'
from /Users/kristianconsult/.rvm/gems/ruby-1.9.1-p378/gems/octopi-0.2.8/lib/octopi/repository.rb:118:in `create'
from /Users/kristianconsult/Development/Languages/Ruby/Apps/Task-apps/Thor-tasks/github_tasks/lib/github.thor:17:in `block in create'
from /Users/kristianconsult/.rvm/gems/ruby-1.9.1-p378/gems/octopi-0.2.8/lib/octopi.rb:33:in `block in authenticated'
Running thor task