create sub_command class - sh19910711/git-contest GitHub Wiki

# lib/contest/command/sub_command.rb
require 'thor'

class SubCommand < Thor
  def self.get_desc
    ['command [options]', 'command description']
  end

  def self.get_command_name
    'sub-command'
  end
  
  desc *get_desc
  def sub_command
  end

  default_task :sub_command

  no_tasks do
    def method1
    end

    def method2
    end
  end
end
# lib/contest/command/main.rb
require 'thor'
require 'contest/command/sub_command'

class Main < Thor
  register SubCommand, SubCommand.get_command_name, *SubCommand.get_desc
end