Sha256: 40c535959bdca5eeeb931e58388015ded3e07f7e4d800420fb018a7e791b79c4

Contents?: true

Size: 1.11 KB

Versions: 8

Compression:

Stored size: 1.11 KB

Contents

# frozen_string_literal: true

module Command
  class Ps < Base
    NAME = "ps"
    OPTIONS = [
      app_option(required: true),
      workload_option
    ].freeze
    DESCRIPTION = "Shows running replicas in app"
    LONG_DESCRIPTION = <<~HEREDOC
      - Shows running replicas in app
    HEREDOC
    EXAMPLES = <<~HEREDOC
      ```sh
      # Shows running replicas in app, for all workloads.
      cpl ps -a $APP_NAME

      # Shows running replicas in app, for a specific workload.
      cpl ps -a $APP_NAME -w $WORKLOAD_NAME
      ```
    HEREDOC

    def call # rubocop:disable Metrics/MethodLength
      workloads = [config.options[:workload]] if config.options[:workload]
      workloads ||= config[:app_workloads] + config[:additional_workloads]

      workloads.each do |workload|
        result = cp.workload_get_replicas(workload, location: config[:default_location])
        if result.nil?
          puts "#{workload}: no workload"
        elsif result["items"].nil?
          puts "#{workload}: no replicas"
        else
          result["items"].each { |replica| puts replica }
        end
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
cpl-0.4.1 lib/command/ps.rb
cpl-0.4.0 lib/command/ps.rb
cpl-0.3.3 lib/command/ps.rb
cpl-0.3.2 lib/command/ps.rb
cpl-0.3.1 lib/command/ps.rb
cpl-0.3.0 lib/command/ps.rb
cpl-0.2.0 lib/command/ps.rb
cpl-0.1.0 lib/command/ps.rb