Methods
protected instance
Included modules
Attributes
config | [R] |
Protected instance methods
execute_action
(emsg="Failed", &action)
[show source]
# File lib/rudy/cli/base.rb, line 65 65: def execute_action(emsg="Failed", &action) 66: begin 67: ret = action.call 68: raise emsg unless ret 69: ret 70: rescue Rudy::AWS::EC2::NoAMI => ex 71: raise Drydock::OptError.new('-a', @alias) 72: end 73: end
execute_check
(level=:medium)
[show source]
# File lib/rudy/cli/base.rb, line 75 75: def execute_check(level=:medium) 76: ret = Annoy.are_you_sure?(level) 77: exit 0 unless ret 78: ret 79: end
init
()
[show source]
# File lib/rudy/cli/base.rb, line 11 11: def init 12: 13: if Drydock.debug? 14: #Caesars.enable_debug 15: Rudy.enable_debug 16: end 17: 18: # The CLI wants output! 19: Rudy::Huxtable.update_logger STDOUT 20: 21: # Send The Huxtables the global values from the command-line 22: Rudy::Huxtable.update_global @global 23: 24: # Reload configuration. This must come after update_global 25: # so it will catch the @@global.config path (if supplied). 26: begin 27: Rudy::Huxtable.update_config 28: rescue Caesars::SyntaxError => ex 29: le ex.message 30: le ex.backtrace if @@global.verbose > 0 31: exit 81 32: end 33: 34: @@global.nocolor ? String.disable_color : String.enable_color 35: @@global.auto ? Annoy.enable_skip : Annoy.disable_skip 36: 37: # ANSI codes look like garbage in DOS 38: if Rudy.sysinfo.os.to_s == 'windows' 39: String.disable_color 40: raise Rudy::Error, 'Ruby 1.9 is not supported (yet)' if Rudy.sysinfo.ruby == [1,9,1] 41: end 42: 43: unless @@global.accesskey && @@global.secretkey 44: le "No AWS credentials. Check your configs!" 45: le "Try: rudy init" 46: exit 1 47: end 48: 49: #if @@global.environment =~ /^prod/ && Rudy.debug? 50: # li Rudy::Utils.banner("PRODUCTION ACCESS IS DISABLED IN DEBUG MODE") 51: # exit 1 52: #end 53: 54: if @@global.verbose >= 4 # -vvvv 55: format = @@global.format == :json ? :json : :yaml 56: gcopy = @@global.dup 57: gcopy.secretkey = "[HIDDEN]" 58: li "# GLOBALS: ", gcopy.dump(format) 59: end 60: 61: Rudy::Metadata.connect @@global.accesskey, @@global.secretkey, @@global.region 62: Rudy::AWS::EC2.connect @@global.accesskey, @@global.secretkey, @@global.region 63: end
machine_separator
(name, awsid)
[show source]
# File lib/rudy/cli/base.rb, line 114 114: def machine_separator(name, awsid) 115: ('%s %-50s awsid: %s ' % [$/, name, awsid]).att(:reverse) 116: end
print_header
()
Print a default header to the screen for every command.
[show source]
# File lib/rudy/cli/base.rb, line 83 83: def print_header 84: 85: # Send The Huxtables the global values again because they could be 86: # updated after initialization but before the command was executed 87: Rudy::Huxtable.update_global @global 88: 89: li Rudy::CLI.generate_header(@@global, @@config) if @@global.print_header 90: 91: unless @@global.quiet 92: if @@global.environment == "prod" 93: msg = "YOU ARE PLAYING WITH PRODUCTION" 94: li Rudy::Utils.banner(msg, :normal), $/ 95: end 96: end 97: end
print_stobject
(obj, noverbose=false)
[show source]
# File lib/rudy/cli/base.rb, line 107 107: def print_stobject(obj, noverbose=false) 108: format = @@global.format 109: format = :yaml if @@global.verbose > 0 && @@global.format == :string 110: format = :string if noverbose || format.to_s == "s" 111: li String === obj ? obj.dump : obj.dump(format) 112: end
print_stobjects
(stobjects=[], noverbose=false)
stobjects is an Array of Storable objects noverbose when not false, will force to print with Object#to_s
[show source]
# File lib/rudy/cli/base.rb, line 101 101: def print_stobjects(stobjects=[], noverbose=false) 102: stobjects.each do |m| 103: print_stobject m, noverbose 104: end 105: end