Method: Inspec::Shell#help

Defined in:
lib/inspec/shell.rb

#help(topic = nil) ⇒ Object



95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
# File 'lib/inspec/shell.rb', line 95

def help(topic = nil)
  if topic.nil?

    puts "      Available commands:\n\n          `[resource]` - run resource on target machine\n          `help resources` - show all available resources that can be used as commands\n          `help [resource]` - information about a specific resource\n          `help matchers` - show information about common matchers\n          `exit` - exit the InSpec shell\n\n      You can use resources in this environment to test the target machine. For example:\n\n          command('uname -a').stdout\n          file('/proc/cpuinfo').content => \"value\"\n\n      \#{print_target_info}\n    EOF\n  elsif topic == \"resources\"\n    resources.sort.each do |resource|\n      puts \" - \#{resource}\"\n    end\n  elsif topic == \"matchers\"\n    print_matchers_help\n  elsif !Inspec::Resource.registry[topic].nil? # TODO: fix unnecessary logic\n    topic_info = Inspec::Resource.registry[topic]\n    info = \"\#{mark \"Name:\"} \#{topic}\\n\\n\"\n    unless topic_info.desc.nil?\n      info += \"\#{mark \"Description:\"}\\n\\n\"\n      info += \"\#{topic_info.desc}\\n\\n\"\n    end\n\n    unless topic_info.example.nil?\n      info += \"\#{mark \"Example:\"}\\n\\n\"\n      info += \"\#{topic_info.example}\\n\\n\"\n    end\n\n    info += \"\#{mark \"Web Reference:\"}\\n\\n\"\n    info += \"https://www.inspec.io/docs/reference/resources/\#{topic}\\n\\n\"\n    puts info\n  else\n    puts \"The resource \#{topic} does not exist. For a list of valid resources, type: help resources\"\n  end\nend\n"