Class: Bogo::Cli::Setup
- Inherits:
-
Object
- Object
- Bogo::Cli::Setup
- Defined in:
- lib/bogo-cli/setup.rb
Class Method Summary collapse
-
.define { ... } ⇒ TrueClass
Wrap slop setup for consistent usage.
-
.output_debug(string) ⇒ Object
Write debug message to UI.
-
.output_error(string) ⇒ Object
Write error message to UI.
Class Method Details
.define { ... } ⇒ TrueClass
Wrap slop setup for consistent usage
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/bogo-cli/setup.rb', line 48 def define(&block) begin slop_result = Slop.parse(:help => true) do instance_exec(&block) end puts slop_result.help exit -1 rescue StandardError, ScriptError => err output_error err. if ENV["DEBUG"] output_debug "Stacktrace: #{err.class}: " \ "#{err.message}\n#{err.backtrace.join("\n")}" if err.respond_to?(:original) && err.original msg = "Original Stacktrace: #{err.original.class}: " \ "#{err.original.message}\n#{err.original.backtrace.join("\n")}" output_debug msg end end exit err.respond_to?(:exit_code) ? err.exit_code : -1 end true end |
.output_debug(string) ⇒ Object
Write debug message to UI. Uses formatted ui if available and falls back to stderr.
87 88 89 90 91 92 93 |
# File 'lib/bogo-cli/setup.rb', line 87 def output_debug(string) if Command.ui Command.ui.debug string else $stderr.puts "DEBUG: #{string}" end end |
.output_error(string) ⇒ Object
Write error message to UI. Uses formatted ui if available and falls back to stderr.
75 76 77 78 79 80 81 |
# File 'lib/bogo-cli/setup.rb', line 75 def output_error(string) if Command.ui Command.ui.error string else $stderr.puts "ERROR: #{string}" end end |