Class: CfScript::Command::Base
- Inherits:
-
Object
- Object
- CfScript::Command::Base
- Includes:
- Runner, UI, UI::NameTag, Singleton
- Defined in:
- lib/cf_script/command/base.rb
Direct Known Subclasses
Apps::AppsCommand, Apps::Base, Apps::DeleteCommand, Apps::EnvCommand, Apps::RenameCommand, Apps::SetEnvCommand, Apps::StopCommand, Apps::UnsetEnvCommand, General::ApiCommand, General::AuthCommand, General::LoginCommand, General::LogoutCommand, General::TargetCommand, Routes::CheckRouteCommand, Routes::CreateRouteCommand, Routes::DeleteRouteCommand, Routes::MapRouteCommand, Routes::RoutesCommand, Routes::UnmapRouteCommand, Spaces::SpaceCommand, Spaces::SpacesCommand
Constant Summary
Constants included from UI
UI::COLORS, UI::EMOJI, UI::TAGS
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Instance Method Summary collapse
- #good_run?(output, options = {}) ⇒ Boolean
-
#initialize(type, name) ⇒ Base
constructor
A new instance of Base.
- #line(env, bin, args) ⇒ Object
- #option_value(options, key, default) ⇒ Object
- #run(*args, &block) ⇒ Object
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(type, name) ⇒ Base
Returns a new instance of Base.
15 16 17 18 |
# File 'lib/cf_script/command/base.rb', line 15 def initialize(type, name) @type = type @name = name end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
8 9 10 |
# File 'lib/cf_script/command/base.rb', line 8 def name @name end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
7 8 9 |
# File 'lib/cf_script/command/base.rb', line 7 def type @type end |
Instance Method Details
#good_run?(output, options = {}) ⇒ Boolean
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/cf_script/command/base.rb', line 32 def good_run?(output, = {}) [:check_status] = option_value(, :check_status, true) [:check_failed] = option_value(, :check_failed, true) if [:check_status] == true && !output.good? error 'cf exited with error' output.dump unless CfScript.config.runtime.echo_output return false end if output.no_api_endpoint? error "No API endpoint set" return false end if output.not_logged_in? error 'Not logged in' return false end if [:check_failed] == true && output.failed? error 'FAILED' output.dump unless CfScript.config.runtime.echo_output return false end true end |
#line(env, bin, args) ⇒ Object
20 21 22 |
# File 'lib/cf_script/command/base.rb', line 20 def line(env, bin, args) Line.new(env, bin, type, name, args) end |
#option_value(options, key, default) ⇒ Object
28 29 30 |
# File 'lib/cf_script/command/base.rb', line 28 def option_value(, key, default) .key?(key) ? [key] : default end |
#run(*args, &block) ⇒ Object
24 25 26 |
# File 'lib/cf_script/command/base.rb', line 24 def run(*args, &block) raise "run called in base command class" end |