module Gauntlt::Support::CliHelper

Public Instance Methods

cli_installed?(bin_name) click to toggle source
# File lib/gauntlt/attack_adapters/support/cli_helper.rb, line 10
def cli_installed?(bin_name)
  `which #{bin_name}` && $CHILD_STATUS.success?
end
ensure_cli_installed(bin) click to toggle source
# File lib/gauntlt/attack_adapters/support/cli_helper.rb, line 14
def ensure_cli_installed(bin)
  raise "#{bin} is not installed or is not in your path" unless cli_installed?(bin)
end
ensure_shell_variable_set(shell_variable) click to toggle source
# File lib/gauntlt/attack_adapters/support/cli_helper.rb, line 18
def ensure_shell_variable_set(shell_variable)
  raise "#{shell_variable} is not set" unless shell_variable_exists?(shell_variable)
end
get_cli_version(bin_name) click to toggle source

this should succeed in getting the version of a command in most situations

# File lib/gauntlt/attack_adapters/support/cli_helper.rb, line 27
def get_cli_version(bin_name)
  return `#{bin_name} --version`.scan(/((\d+\.)?(\d+\.)?(\*|\d+))/)[0][0]
end
get_shell_variable(shell_variable) click to toggle source
# File lib/gauntlt/attack_adapters/support/cli_helper.rb, line 22
def get_shell_variable(shell_variable)
  ENV[shell_variable]
end
shell_variable_exists?(shell_variable) click to toggle source
# File lib/gauntlt/attack_adapters/support/cli_helper.rb, line 31
def shell_variable_exists?(shell_variable)
  path = get_shell_variable(shell_variable)
  File.exists?(path) if path
end