class MacSetup::Shell

Public Class Methods

ask(question) click to toggle source
# File lib/mac_setup/shell.rb, line 20
def ask(question)
  puts question
  STDIN.gets.strip
end
command_present?(command) click to toggle source
# File lib/mac_setup/shell.rb, line 34
def command_present?(command)
  success?("command -v #{command} >/dev/null 2>&1")
end
password() click to toggle source
# File lib/mac_setup/shell.rb, line 25
def password
  puts "Enter Password"
  STDIN.noecho(&:gets).strip
end
raw(command) click to toggle source
# File lib/mac_setup/shell.rb, line 16
def raw(command)
  system(command)
end
result(*command) click to toggle source
# File lib/mac_setup/shell.rb, line 8
def result(*command)
  run(*command).output
end
run(*command) click to toggle source
# File lib/mac_setup/shell.rb, line 12
def run(*command)
  Result.new(*Open3.capture3(*command))
end
sanitize_command(command) click to toggle source
# File lib/mac_setup/shell.rb, line 38
def sanitize_command(command)
  if command.respond_to?(:each)
    Shellwords.join(command)
  else
    command
  end
end
success?(command) click to toggle source
# File lib/mac_setup/shell.rb, line 30
def success?(command)
  run(command).success?
end