Sha256: a7c4e5adea03a596be7fc3440e4f067af02c33d021dadd90a393ebc0bab55275

Contents?: true

Size: 1.13 KB

Versions: 12

Compression:

Stored size: 1.13 KB

Contents

# frozen_string_literal: true

require 'uffizzi'
require 'uffizzi/config_file'

module Uffizzi
  class Cli::Status < Thor
    include ApiClient

    default_task :describe

    desc 'describe', 'Show account status'
    def describe
      Uffizzi::AuthHelper.check_login

      account_name = ConfigFile.read_option(:account)[:name]
      response = fetch_account(ConfigFile.read_option(:server), account_name)

      if ResponseHelper.ok?(response)
        handle_describe_success_response(response)
      elsif ResponseHelper.not_found?(response)
        Uffizzi.ui.say("Account with name #{account_name} does not exist")
      else
        ResponseHelper.handle_failed_response(response)
      end
    end

    private

    def handle_describe_success_response(response)
      account = response[:body][:account]
      account_rendered_params = {
        account: account[:name],
        plan: "Uffizzi #{account[:product_name]}",
        api: account[:api_url],
        controller: account[:vclusters_controller_url],
      }

      Uffizzi.ui.output_format = Uffizzi::UI::Shell::PRETTY_LIST
      Uffizzi.ui.say(account_rendered_params)
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
uffizzi-cli-2.4.11 lib/uffizzi/cli/status.rb
uffizzi-cli-2.4.10 lib/uffizzi/cli/status.rb
uffizzi-cli-2.4.9 lib/uffizzi/cli/status.rb
uffizzi-cli-2.4.8 lib/uffizzi/cli/status.rb
uffizzi-cli-2.4.7 lib/uffizzi/cli/status.rb
uffizzi-cli-2.4.6 lib/uffizzi/cli/status.rb
uffizzi-cli-2.4.5 lib/uffizzi/cli/status.rb
uffizzi-cli-2.4.4 lib/uffizzi/cli/status.rb
uffizzi-cli-2.4.3 lib/uffizzi/cli/status.rb
uffizzi-cli-2.4.2 lib/uffizzi/cli/status.rb
uffizzi-cli-2.4.1 lib/uffizzi/cli/status.rb
uffizzi-cli-2.4.0 lib/uffizzi/cli/status.rb