Sha256: baad1d6990cb6f6437e07e976f6ccdce5ad12f02362b6d9124bbf12c82eb1d34

Contents?: true

Size: 1.19 KB

Versions: 1

Compression:

Stored size: 1.19 KB

Contents

# frozen_string_literal: true

module Superbot
  module CLI
    class TeleportCommand < Clamp::Command
      include Superbot::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'
      option ['-u', '--user'], 'AUTH_USER_NAME', 'Cloud webdriver auth credentials', environment_variable: 'AUTH_USER_NAME', attribute_name: :auth_user
      option ['-p', '--password'], 'AUTH_USER_PASSWORD', 'Cloud webdriver auth credentials', environment_variable: 'AUTH_USER_PASSWORD', attribute_name: :auth_password

      def execute
        @web = Superbot::Web.new(
          webdriver_type: browser,
          auth_user: auth_user,
          auth_password: auth_password
        ).tap(&:run_async_after_running!)

        @chromedriver = Kommando.run_async 'chromedriver --silent --port=9515' if browser == 'local'
        puts "", "🤖 Teleport is active ☁️ "

        $stdin.gets
      ensure
        close_teleport
      end

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

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
superbot-0.1.9 lib/superbot/cli/teleport_command.rb