Sha256: 515463f5260e4c9d4d919edc990ca7ba9f9cf3272fd32640561b0572f5c47364

Contents?: true

Size: 1.39 KB

Versions: 1

Compression:

Stored size: 1.39 KB

Contents

# frozen_string_literal: true

require_relative "new_command"
require_relative "run_command"
require_relative "version_command"
require_relative "record_command"

module Superbot
  module CLI
    class RootCommand < Clamp::Command
      banner "superbot 🤖"

      option ['-v', '--version'], :flag, "Show version information" do
        puts Superbot::VERSION
        exit(0)
      end

      subcommand ["version"], "Show version information", VersionCommand
      subcommand ["record"], "Open browser with selenium ide pre-loaded", RecordCommand if ENV['SUPERBOT_FEAT_RECORD'] == 'true'
      if ENV['SUPERBOT_FEAT_PROJECT'] == 'true'
        subcommand ["new"], "Create a new project", NewCommand
        subcommand ["run"], "Run a project", RunCommand
      end

      if defined?(::Superbot::Cloud::CLI::RootCommand)
        subcommand ["cloud"], "Show cloud commands", ::Superbot::Cloud::CLI::RootCommand
      end

      if defined?(::Superbot::Teleport::CLI::RootCommand)
        subcommand ["teleport"], "Open teleport to the cloud", ::Superbot::Teleport::CLI::RootCommand
      end

      def self.run
        super
      rescue StandardError => exc
        warn exc.message
        warn exc.backtrace.join("\n")
      end

      def subcommand_missing(name)
        return super unless name == 'local'

        abort "Subcommand '#{name}' requires gem superbot-#{name} to be installed"
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
superbot-0.1.28 lib/superbot/cli/root_command.rb