Module: Thor::Base::ClassMethods

Defined in:
lib/cinch/bot_template/main/thor.rb

Instance Method Summary collapse

Instance Method Details



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/cinch/bot_template/main/thor.rb', line 26

def print_options(shell, options, group_name = nil)
  return if options.empty?

  list    = []
  padding = options.map { |o| o.aliases.size }.max.to_i * 4

  options.each do |option|
    next if option.hide
    item = [option.usage(padding)]
    item.push(option.description ? "# #{option.description}" : "")

    list << item
    list << ["", "# Default: #{option.default}"] if option.show_default?
    list << ["", "# Possible values: #{option.enum.join(', ')}"] if option.enum
  end

  shell.say(group_name ? "#{group_name} options:" : "Options:") unless list.empty?
  shell.print_table(list, :indent => 2) unless list.empty?
  #shell.say ""
end