module Subcommands
override the output from optparse to be a bit more aesthetically pleasing
Public Instance Methods
command(*names) { |opts| ... }
click to toggle source
# File lib/aws-carb/monkey_patches.rb, line 61 def command *names name = names.shift @commands ||= {} @aliases ||= {} names.each { |n| @aliases[n.to_s] = name.to_s } if names.length > 0 opt = lambda do OptionParser.new do |opts| yield opts opts.banner << "OPTIONS" end end @commands[name.to_s] = opt end
print_actions()
click to toggle source
# File lib/aws-carb/monkey_patches.rb, line 46 def print_actions subcommand_help = "#{'SUBCOMMAND'.colorize({:color => :white, :mode => :bold})}\n" @commands.each_pair do |c, opt| subcommand_help << "\n #{c} - #{opt.call.description}" end unless @aliases.empty? subcommand_help << "\n\naliases: \n" @aliases.each_pair { |name, val| subcommand_help << " #{name} - #{val}\n" } end subcommand_help << "\n\n help <command> - for more information on a specific command\n\n" end