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.
Class Method Details
.define { ... } ⇒ TrueClass
Wrap slop setup for consistent usage
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/bogo-cli/setup.rb', line 46 def define(&block) begin slop_result = Slop.parse(:help => true) do instance_exec(&block) end puts slop_result.help exit -1 rescue Bogo::Config::FileLoadError => e $stderr.puts "ERROR: #{[e, e.original].compact.join(' - ')}" if(ENV['DEBUG']) $stderr.puts "Stacktrace: #{e.original.class}: #{e.original.message}\n#{e.original.backtrace.join("\n")}" end exit e.respond_to?(:exit_code) ? e.exit_code : -1 rescue StandardError, ScriptError => e if(ENV['DEBUG']) $stderr.puts "ERROR: #{e.class}: #{e.message}\n#{e.backtrace.join("\n")}" else $stderr.puts "ERROR: #{e.class}: #{e.message}" end exit e.respond_to?(:exit_code) ? e.exit_code : -1 end true end |