class Inspec::EnvPrinter

Constants

EVAL_COMMANDS

Attributes

shell[R]

Public Class Methods

new(command_class, shell = nil) click to toggle source
# 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

Public Instance Methods

print_and_exit!() click to toggle source

Private Instance Methods

completion_dir() click to toggle source
# File lib/inspec/env_printer.rb, line 50
def completion_dir
  File.join(File.dirname(__FILE__), "completions")
end
completion_template_path() click to toggle source
# File lib/inspec/env_printer.rb, line 54
def completion_template_path
  File.join(completion_dir, "#{@shell}.sh.erb")
end
exit_no_completion() click to toggle source
# File lib/inspec/env_printer.rb, line 85
def exit_no_completion
  $stderr.puts "# No completion script for #{@shell}!"
  print_detection_warning($stderr) if @detected
  exit 1
end
exit_no_shell() click to toggle source
# File lib/inspec/env_printer.rb, line 91
    def exit_no_shell
      if @detected
        $stderr.puts "# Unable to automatically detect shell and no shell was provided."
      end
      $stderr.puts <<~EOF
        #
        # Please provide the name of your shell via the command line:
        #
        #    inspec env SHELLNAME
        #
        # Currently supported shells are: #{shells_with_completions.join(", ")}
      EOF
      exit 1
    end
have_shell?() click to toggle source
# File lib/inspec/env_printer.rb, line 42
def have_shell?
  !(@shell.nil? || @shell.empty?)
end
have_shell_completion?() click to toggle source
# File lib/inspec/env_printer.rb, line 46
def have_shell_completion?
  File.exist?(completion_template_path)
end
print_completion_for_shell() click to toggle source
print_detection_warning(device) click to toggle source
print_usage_guidance() click to toggle source
shells_with_completions() click to toggle source
# File lib/inspec/env_printer.rb, line 58
def shells_with_completions
  Dir.glob("#{completion_dir}/*.sh.erb").map { |f| File.basename(f, ".sh.erb") }
end