Sha256: 81128d6faf8fe28666d5877248571ca4df3e551d25652a16735452c46ece270c

Contents?: true

Size: 666 Bytes

Versions: 2

Compression:

Stored size: 666 Bytes

Contents

module Bard
  class RemoteCommand < Struct.new(:server, :command, :home)
    def local_command
      uri = URI.parse("ssh://#{server.ssh}")
      ssh_key = server.ssh_key ? "-i #{server.ssh_key} " : ""
      cmd = command
      if server.env
        cmd = "#{server.env} #{command}"
      end
      unless home
        cmd = "cd #{server.path} && #{cmd}"
      end
      cmd = "ssh -tt #{ssh_key}#{"-p#{uri.port} " if uri.port}#{uri.user}@#{uri.host} '#{cmd}'"
      if server.gateway
        uri = URI.parse("ssh://#{server.gateway}")
        cmd = "ssh -tt #{" -p#{uri.port} " if uri.port}#{uri.user}@#{uri.host} \"#{cmd}\""
      end
      cmd
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
bard-0.67.0 lib/bard/remote_command.rb
bard-0.66.0 lib/bard/remote_command.rb