Class: CfScript::Command::General::ApiCommand

Inherits:
Base
  • Object
show all
Defined in:
lib/cf_script/command/cf/general/api.rb

Constant Summary collapse

API_NOT_SET =
'No api endpoint set'
API_ENDPOINT_REGEX =
%r|API endpoint:\s+(?<url>https?://[\S]+)\s+\(API version:\s+(?<version>[^)]+)\)|

Constants included from UI

UI::COLORS, UI::EMOJI, UI::TAGS

Instance Attribute Summary

Attributes inherited from Base

#name, #type

Instance Method Summary collapse

Methods inherited from Base

#good_run?, #line, #option_value

Methods included from UI::NameTag

#alert, #detail, #error, #info, #name_tag, #progress, #step, #success, #title

Methods included from UI

alert, call_type, debug, detail, emoji, emoji_for, error, info, print_err, print_out, progress, puts_err, puts_out, step, success, tag_char, tag_close, tag_color, tag_format, tag_open, tag_style, title, trace, ui_format, with_color_of

Methods included from Runner

cf_bin, cf_env, cf_id, cf_in_env?, cf_in_path?, cf_path, cf_version, run_cf, which_cf

Constructor Details

#initializeApiCommand

Returns a new instance of ApiCommand.



7
8
9
# File 'lib/cf_script/command/cf/general/api.rb', line 7

def initialize
  super(:general, :api)
end

Instance Method Details

#run(url = nil, &block) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
# File 'lib/cf_script/command/cf/general/api.rb', line 11

def run(url = nil, &block)
  run_cf self, url do |output|
    return unless good_run?(output)

    if output.contains? API_NOT_SET
      error API_NOT_SET
    else
      build_endpoint(output)
    end
  end
end