Skip to content

@deadlyicon /canhaz.rb
Created

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
canhaz
# -*- encoding: utf-8 -*-
require 'thor'
require 'pathname'
module Canhaz
class Commands < Thor
desc "deploy","deploy"
def deploy
puts "deploying"
end
class Recipes < Thor
desc "apply", "apply"
def apply
puts "applying"
end
end
desc "recipes", "recipes"
subcommand :recipes, Recipes
end
end
Canhaz::Commands.start(ARGV)
# THIS IS WHAT I GET
# ./bin/canhaz -h
# Tasks:
# canhaz apply # apply
# canhaz deploy # deploy
# canhaz help [COMMAND] # Describe subcommands or one specific subcommand
# canhaz help [TASK] # Describe available tasks or one specific task
# canhaz recipes # recipes
# ./bin/canhaz recipes -h
# Tasks:
# canhaz apply # apply
# canhaz help [COMMAND] # Describe subcommands or one specific subcommand
# THIS IS WHAT I WANT
# ./bin/canhaz -h
# Tasks:
# canhaz deploy # deploy
# canhaz recipes # recipes
# canhaz recipes apply # apply
# canhaz help [COMMAND] # Describe subcommands or one specific subcommand
# canhaz help [TASK] # Describe available tasks or one specific task
# ./bin/canhaz recipes -h
# Tasks:
# canhaz recipes apply # apply
# canhaz recipes help [COMMAND] # Describe subcommands or one specific subcommand
class Canhaz::Thor < ::Thor
class << self
attr_accessor :superthor, :superthor_name
def basename
superthor ? "#{superthor.basename} #{superthor_name}" : superthor
end
def subcommand(subcommand, subcommand_class)
self.subcommands << subcommand.to_s
subcommand_class.subcommand_help subcommand
subcommand_class.superthor = self
subcommand_class.superthor_name = subcommand
define_method(subcommand) { |*args| invoke subcommand_class, args }
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.