Sha256: ec601424ecac50b6869e2bad1f830cba00b7a90acc49e0aac494b29a4bf5b1b8

Contents?: true

Size: 917 Bytes

Versions: 1

Compression:

Stored size: 917 Bytes

Contents

require 'taketo/commands/ssh_command'
require 'taketo/actions/base_action'
require 'taketo/server_resolver'

module Taketo
  module Actions

    class Login < BaseAction
      def run
        server = ServerResolver.new(config, destination_path).resolve
        server_command = remote_command(server)
        command_to_execute = Commands::SSHCommand.new(server).render(server_command.render(server, options))
        execute(command_to_execute)
      end

      private

      def remote_command(server)
        command = options[:command]
        if String(command).empty?
          server.default_command
        else
          server.find_command(command.to_sym) || Constructs::Command.explicit_command(command)
        end
      end

      def execute(shell_command)
        if options[:dry_run]
          puts shell_command
        else
          system shell_command
        end
      end
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
taketo-0.2.0 lib/taketo/actions/login.rb