module ChefApply::CLI::Help

Constants

T

Public Instance Methods

format_flags() click to toggle source
# File lib/chef_apply/cli/help.rb, line 32
def format_flags
  flag_text = "FLAGS:\n"
  justify_length = 0
  options.each_value do |spec|
    justify_length = [justify_length, spec[:long].length + 4].max
  end
  options.sort.to_h.each_value do |flag_spec|
    short = flag_spec[:short] || "  "
    short = short[0, 2] # We only want the flag portion, not the capture portion (if present)
    if short == "  "
      short = "    "
    else
      short = "#{short}, "
    end
    flags = "#{short}#{flag_spec[:long]}"
    flag_text << "    #{flags.ljust(justify_length)}    "
    ml_padding = " " * (justify_length + 8)
    first = true
    flag_spec[:description].split("\n").each do |d|
      flag_text << ml_padding unless first
      first = false
      flag_text << "#{d}\n"
    end
  end
  flag_text
end
format_help() click to toggle source
# File lib/chef_apply/cli/help.rb, line 26
def format_help
  help_text = banner.clone # This prevents us appending to the banner text
  help_text << "\n"
  help_text << format_flags
end
show_help() click to toggle source
# File lib/chef_apply/cli/help.rb, line 22
def show_help
  UI::Terminal.output format_help
end
show_version() click to toggle source
# File lib/chef_apply/cli/help.rb, line 63
def show_version
  require_relative "../version"
  UI::Terminal.output T.version.show(ChefApply::VERSION)
end
usage() click to toggle source
# File lib/chef_apply/cli/help.rb, line 59
def usage
  T.usage
end