Method: GitSSHWrapper::CLI#call

Defined in:
lib/git-ssh-wrapper/cli.rb

#callObject



32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/git-ssh-wrapper/cli.rb', line 32

def call
  if %w[--help -h help].include?(key)
    print_help
  end

  if %w[--version -v].include?(key)
    print_version
  end

  if key.nil? || command.empty?
    error
  elsif !File.exist?(key)
    error "private key not found: #{key.inspect}"
  end

  GitSSHWrapper.with_wrapper(:private_key_path => key) do |wrapper|
    wrapper.set_env
    system *command
    exit $?.exitstatus
  end

  exit 1
end