From 8e9d8d9e0837104d684547464ba3d0aa8f8e60ea Mon Sep 17 00:00:00 2001 From: Nat Lasseter Date: Mon, 9 Nov 2020 16:40:02 +0000 Subject: Updated config parsing: catch command line errors thrown by parser --- lib/longboat/config.rb | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) (limited to 'lib/longboat') diff --git a/lib/longboat/config.rb b/lib/longboat/config.rb index cd27bf9..dffbc08 100644 --- a/lib/longboat/config.rb +++ b/lib/longboat/config.rb @@ -27,15 +27,29 @@ module Longboat exit rescue Optimist::VersionNeeded exit + rescue Optimist::CommandlineError => e + puts "Command line error:" + puts e.message + puts + puts "Try --help, or refer to raider documentation." + exit 1 end end def self.for_raider(&block) parser = Optimist::Parser.new(&block) parser.ignore_invalid_options = true - opts = parser.parse - opts.delete(:help) - opts + begin + opts = parser.parse + opts.delete(:help) + opts + rescue Optimist::CommandlineError => e + puts "Command line error:" + puts e.message + puts + puts "Try --help, or refer to raider documentation." + exit 1 + end end end end -- cgit v1.2.1