Sha256: 66bc122cc94296667f73e388b49e08536a28e1ea678f13d72df3e55154e99dd0

Contents?: true

Size: 870 Bytes

Versions: 5

Compression:

Stored size: 870 Bytes

Contents

require 'fileutils'
require 'launchy'
require 'io/console'
require 'pathname'

module Terminalwire
  module Client
    ROOT_PATH = "~/.terminalwire".freeze
    def self.root_path = Pathname.new(ENV.fetch("TERMINALWIRE_HOME", ROOT_PATH))

    def self.websocket(url:, arguments: ARGV, &configuration)
      ENV["TERMINALWIRE_HOME"] ||= root_path.to_s

      url = URI(url)

      Async do |task|
        endpoint = Async::HTTP::Endpoint.parse(
          url,
          alpn_protocols: Async::HTTP::Protocol::HTTP11.names
        )

        Async::WebSocket::Client.connect(endpoint) do |adapter|
          transport = Terminalwire::Transport::WebSocket.new(adapter)
          adapter = Terminalwire::Adapter::Socket.new(transport)
          Terminalwire::Client::Handler.new(adapter, arguments:, endpoint:, &configuration).connect
        end
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
terminalwire-0.2.5 lib/terminalwire/client.rb
terminalwire-0.2.4 lib/terminalwire/client.rb
terminalwire-0.2.3 lib/terminalwire/client.rb
terminalwire-0.2.2 lib/terminalwire/client.rb
terminalwire-0.2.1 lib/terminalwire/client.rb