Class: CfScript::Command::General::TargetCommand
- Defined in:
- lib/cf_script/command/cf/general/target.rb
Constant Summary collapse
- NOT_LOGGED_IN =
'Not logged in'
Constants included from UI
UI::COLORS, UI::EMOJI, UI::TAGS
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
-
#initialize ⇒ TargetCommand
constructor
A new instance of TargetCommand.
- #run(space_name_or_target = nil, &block) ⇒ Object
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
#initialize ⇒ TargetCommand
Returns a new instance of TargetCommand.
5 6 7 |
# File 'lib/cf_script/command/cf/general/target.rb', line 5 def initialize super(:general, :target) end |
Instance Method Details
#run(space_name_or_target = nil, &block) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/cf_script/command/cf/general/target.rb', line 9 def run(space_name_or_target = nil, &block) args = build_args(space_name_or_target) space = args.first && args.first.key?(:s) ? args.first[:s] : '' run_cf self, *args do |output| return nil unless good_run?(output, check_failed: false) # TODO: check org not found too if output.not_found?('Space', space) error "Space #{space} not found" return end if target = build_target(output) block ? yield(target) : target else error 'object is nil' end end end |