Method: Inspec::Shell#help

Defined in:
lib/inspec/shell.rb

#help(resource = nil) ⇒ Object



66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
# File 'lib/inspec/shell.rb', line 66

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

    ctx = @runner.backend
    puts <<EOF

Available commands:

`[resource]` - run resource on target machine
`help resources` - show all available resources that can be used as commands
`help [resource]` - information about a specific resource
`exit` - exit the InSpec shell

You can use resources in this environment to test the target machine. For example:

command('uname -a').stdout
file('/proc/cpuinfo').content => "value",

You are currently running on:

OS family:  #{mark ctx.os[:family] || 'unknown'}
OS release: #{mark ctx.os[:release] || 'unknown'}

EOF
  elsif resource == 'resources'
    resources
  elsif !Inspec::Resource.registry[resource].nil?
    puts <<EOF
#{mark 'Name:'} #{resource}

#{mark 'Description:'}

#{Inspec::Resource.registry[resource].desc}

#{mark 'Example:'}
#{print_example(Inspec::Resource.registry[resource].example)}

#{mark 'Web Reference:'}

https://github.com/chef/inspec/blob/master/docs/resources.rst##{resource}

EOF
  else
    puts 'Only the following resources are available:'
    resources
  end
end