Module: Heirloom::CLI
- Defined in:
- lib/heirloom/cli.rb,
lib/heirloom/cli/tag.rb,
lib/heirloom/cli/list.rb,
lib/heirloom/cli/show.rb,
lib/heirloom/cli/setup.rb,
lib/heirloom/cli/rotate.rb,
lib/heirloom/cli/shared.rb,
lib/heirloom/cli/upload.rb,
lib/heirloom/cli/catalog.rb,
lib/heirloom/cli/cleanup.rb,
lib/heirloom/cli/destroy.rb,
lib/heirloom/cli/download.rb,
lib/heirloom/cli/teardown.rb,
lib/heirloom/cli/authorize.rb,
lib/heirloom/cli/formatter/show.rb,
lib/heirloom/cli/formatter/catalog.rb
Defined Under Namespace
Modules: Formatter, Shared
Classes: Authorize, Catalog, Cleanup, Destroy, Download, List, Rotate, Setup, Show, Tag, Teardown, Upload
Class Method Summary
collapse
Class Method Details
.commands ⇒ Object
73
74
75
76
77
78
79
80
81
82
|
# File 'lib/heirloom/cli.rb', line 73
def self.commands
return @commands if @commands
klasses = Heirloom::CLI.constants.reject { |c| [:Shared, :Formatter].include?(c) }
@commands = klasses.map do |klass|
Hashie::Mash.new.tap do |h|
h[:command_name] = klass.downcase
h[:command_summary] = Heirloom::CLI.const_get(klass).command_summary
end
end
end
|
.length_of_longest_command ⇒ Object
84
85
86
|
# File 'lib/heirloom/cli.rb', line 84
def self.length_of_longest_command
@length ||= commands.map { |c| c.command_name.length }.max
end
|
.usage ⇒ Object
59
60
61
62
63
64
65
66
67
68
69
70
71
|
# File 'lib/heirloom/cli.rb', line 59
def self.usage
puts ''
puts 'Usage: heirloom command [options]'
puts ''
puts 'Append -h for help on specific command.'
puts ''
puts 'Commands:'
commands.each do |cmd|
$stdout.printf " %-#{length_of_longest_command}s %s\n",
cmd.command_name,
cmd.command_summary
end
end
|