Class: CfScript::Command::General::LoginCommand
- Defined in:
- lib/cf_script/command/cf/general/login.rb
Constant Summary
Constants included from UI
UI::COLORS, UI::EMOJI, UI::TAGS
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
-
#initialize ⇒ LoginCommand
constructor
A new instance of LoginCommand.
- #run(username, password, options = {}, &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 ⇒ LoginCommand
Returns a new instance of LoginCommand.
3 4 5 |
# File 'lib/cf_script/command/cf/general/login.rb', line 3 def initialize super(:general, :login) end |
Instance Method Details
#run(username, password, options = {}, &block) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/cf_script/command/cf/general/login.rb', line 7 def run(username, password, = {}, &block) args = [{ u: username, p: password }] if [:api] args.last[:a] = [:api] end if [:org] args.last[:o] = [:org] end if [:space] args.last[:s] = [:space] end run_cf self, *args do |output| unless good_run?(output, check_failed: false) if output.credentials_rejected? error 'Credentials were rejected' else output.dump end return false else if logged_in = output.authenticated? block_given? ? yield(logged_in) : logged_in else error 'Not logged in' return false end end end end |