module Naplug::Helpers::CLI::ClassMethods

Public Instance Methods

with_standard_exception_handling(parser) { || ... } click to toggle source
# File lib/naplug/helpers/cli.rb, line 18
def with_standard_exception_handling parser
  begin
    yield
  rescue CommandlineError => e
    plugin = Naplug::Plugin.new :cli, Proc.new { true }, {}
    plugin.output! e.message
    print "%s: %s\n" % [plugin.status.to_s,plugin.output]
    exit plugin.status.to_i
  rescue HelpNeeded
    parser.educate
    exit
  rescue VersionNeeded
    puts parser.version
    exit
  end
end