Method: Inspec::Shell#help

Defined in:
lib/inspec/shell.rb

#help(resource = nil) ⇒ Object



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
140
141
142
143
144
# File 'lib/inspec/shell.rb', line 97

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

    ctx = @runner.backend
    puts "\nAvailable 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`exit` - exit the InSpec shell\n\nYou can use resources in this environment to test the target machine. For example:\n\ncommand('uname -a').stdout\nfile('/proc/cpuinfo').content => \"value\",\n\nYou are currently running on:\n\nOS platform:  \#{mark ctx.os[:name] || 'unknown'}\nOS family:  \#{mark ctx.os[:family] || 'unknown'}\nOS release: \#{mark ctx.os[:release] || 'unknown'}\n\n"
  elsif resource == 'resources'
    resources
  elsif !Inspec::Resource.registry[resource].nil?
    puts "\#{mark 'Name:'} \#{resource}\n\n\#{mark 'Description:'}\n\n\#{Inspec::Resource.registry[resource].desc}\n\n\#{mark 'Example:'}\n\#{print_example(Inspec::Resource.registry[resource].example)}\n\n\#{mark 'Web Reference:'}\n\nhttps://github.com/chef/inspec/blob/master/docs/resources.rst#\#{resource}\n\n"
  else
    puts 'Only the following resources are available:'
    resources
  end
end