Sha256: 7d6ed96febeffa015a8fd651b375f85723e0650e485b32716e0dc9e8a2d58b09

Contents?: true

Size: 1.07 KB

Versions: 3

Compression:

Stored size: 1.07 KB

Contents

# frozen_string_literal: true

require "superbot/cloud/cli/cloud/validations"

module Superbot
  module CLI
    class TeleportCommand < Clamp::Command
      include Superbot::Validations
      include Superbot::Cloud::Validations

      option ['--browser'], 'BROWSER', "Browser type to use. Can be either local or cloud", default: 'cloud' do |browser|
        validates_browser_type browser
      end
      option ['--region'], 'REGION', 'Region for remote webdriver'

      def execute
        require_login unless browser == 'local'

        @web = Superbot::Web.new(webdriver_type: browser, region: region)
        @web.run_async_after_running!

        @chromedriver = Kommando.run_async 'chromedriver --silent --port=9515' if browser == 'local'

        puts "", "🤖 Teleport is open ☁️ "
        puts "", "Configure your webdriver to http://localhost:4567/wd/hub"
        puts "", "Press [enter] to close teleport"

        $stdin.gets
      ensure
        close_teleport
      end

      def close_teleport
        @chromedriver&.kill
        @web&.quit!
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
superbot-0.1.18 lib/superbot/cli/teleport_command.rb
superbot-0.1.17 lib/superbot/cli/teleport_command.rb
superbot-0.1.16 lib/superbot/cli/teleport_command.rb