class Inspec::EnvPrinter::TemplateContext
Public Class Methods
new(command_class)
click to toggle source
# File lib/inspec/env_printer.rb, line 107 def initialize(command_class) @command_class = command_class end
Public Instance Methods
commands_for_thor_class(thor_class)
click to toggle source
# File lib/inspec/env_printer.rb, line 143 def commands_for_thor_class(thor_class) thor_class.all_commands.values.map { |c| c.usage.split.first } end
descript_line_for_command(c)
click to toggle source
# File lib/inspec/env_printer.rb, line 151 def descript_line_for_command(c) "#{c.usage.split.first}:#{Shellwords.escape(c.description)}" end
descript_lines_for_class(thor_class)
click to toggle source
# File lib/inspec/env_printer.rb, line 147 def descript_lines_for_class(thor_class) thor_class.all_commands.values.map { |c| descript_line_for_command(c) } end
get_bindings()
click to toggle source
# File lib/inspec/env_printer.rb, line 111 def get_bindings # rubocop:disable Naming/AccessorMethodName binding end
subcommands_with_commands()
click to toggle source
# File lib/inspec/env_printer.rb, line 127 def subcommands_with_commands ret = {} @command_class.subcommand_classes.each do |k, v| ret[k] = commands_for_thor_class(v) end ret end
subcommands_with_commands_and_descriptions()
click to toggle source
# File lib/inspec/env_printer.rb, line 135 def subcommands_with_commands_and_descriptions ret = {} @command_class.subcommand_classes.each do |k, v| ret[k] = descript_lines_for_class(v) end ret end
top_level_commands()
click to toggle source
The following functions all assume that @command_class is something that provides a Thor-like API
# File lib/inspec/env_printer.rb, line 119 def top_level_commands commands_for_thor_class(@command_class) end
top_level_commands_with_descriptions()
click to toggle source
# File lib/inspec/env_printer.rb, line 123 def top_level_commands_with_descriptions descript_lines_for_class(@command_class) end