Class: Inspec::EnvPrinter

Inherits:
Object
  • Object
show all
Defined in:
lib/inspec/env_printer.rb

Defined Under Namespace

Classes: TemplateContext

Constant Summary collapse

EVAL_COMMANDS =
{
  'bash' => 'eval \"$(inspec env bash)\"',
  'fish' => 'inspec env fish > ~/.config/fish/completions/inspec.fish',
  'zsh' => 'eval \"$(inspec env zsh)\"',
}.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(command_class, shell = nil) ⇒ EnvPrinter

Returns a new instance of EnvPrinter.



16
17
18
19
20
21
22
23
24
# File 'lib/inspec/env_printer.rb', line 16

def initialize(command_class, shell = nil)
  if !shell
    @detected = true
    @shell = Inspec::ShellDetector.new.shell
  else
    @shell = shell
  end
  @command_class = command_class
end

Instance Attribute Details

#shellObject (readonly)

Returns the value of attribute shell.



8
9
10
# File 'lib/inspec/env_printer.rb', line 8

def shell
  @shell
end

Instance Method Details



26
27
28
29
30
31
32
33
34
# File 'lib/inspec/env_printer.rb', line 26

def print_and_exit!
  exit_no_shell if !have_shell?
  exit_no_completion if !have_shell_completion?

  print_completion_for_shell
  print_detection_warning($stdout) if @detected
  print_usage_guidance
  exit 0
end