lib/command/ps.rb in cpl-0.4.1 vs lib/command/ps.rb in cpl-0.5.0

- old
+ new

@@ -6,35 +6,32 @@ OPTIONS = [ app_option(required: true), workload_option ].freeze DESCRIPTION = "Shows running replicas in app" - LONG_DESCRIPTION = <<~HEREDOC + LONG_DESCRIPTION = <<~DESC - Shows running replicas in app - HEREDOC - EXAMPLES = <<~HEREDOC + DESC + EXAMPLES = <<~EX ```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 + EX - def call # rubocop:disable Metrics/MethodLength + def call + cp.fetch_gvc! + workloads = [config.options[:workload]] if config.options[:workload] workloads ||= config[:app_workloads] + config[:additional_workloads] - workloads.each do |workload| + cp.fetch_workload!(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 + result["items"].each { |replica| puts replica } end end end end