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.



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

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.



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

def shell
  @shell
end

Instance Method Details



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

def print_and_exit!
  exit_no_shell unless have_shell?
  exit_no_completion unless have_shell_completion?

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