Sha256: 878bd5ae83aa267c20a23642d89bed93ae4ae6ee16b80201b345bdad27fb4816

Contents?: true

Size: 880 Bytes

Versions: 16

Compression:

Stored size: 880 Bytes

Contents

# frozen_string_literal: true

module Command
  class Open < Base
    NAME = "open"
    OPTIONS = [
      app_option(required: true),
      workload_option
    ].freeze
    DESCRIPTION = "Opens the app endpoint URL in the default browser"
    LONG_DESCRIPTION = <<~DESC
      - Opens the app endpoint URL in the default browser
    DESC
    EXAMPLES = <<~EX
      ```sh
      # Opens the endpoint of the default workload (`one_off_workload`).
      cpl open -a $APP_NAME

      # Opens the endpoint of a specific workload.
      cpl open -a $APP_NAME -w $WORKLOAD_NAME
      ```
    EX

    def call
      workload = config.options[:workload] || config[:one_off_workload]
      data = cp.fetch_workload!(workload)
      url = data["status"]["endpoint"]
      opener = `which xdg-open open`.split("\n").grep_v("not found").first

      exec %(#{opener} "#{url}")
    end
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
cpl-1.4.0 lib/command/open.rb
cpl-1.3.0 lib/command/open.rb
cpl-1.2.0 lib/command/open.rb
cpl-1.1.2 lib/command/open.rb
cpl-1.1.2.rc.0 lib/command/open.rb
cpl-1.1.1 lib/command/open.rb
cpl-1.1.0 lib/command/open.rb
cpl-1.0.4 lib/command/open.rb
cpl-1.0.3 lib/command/open.rb
cpl-1.0.2 lib/command/open.rb
cpl-1.0.1 lib/command/open.rb
cpl-1.0.0 lib/command/open.rb
cpl-0.7.0 lib/command/open.rb
cpl-0.6.0 lib/command/open.rb
cpl-0.5.1 lib/command/open.rb
cpl-0.5.0 lib/command/open.rb