lib/mercenary/program.rb in mercenary-0.2.1 vs lib/mercenary/program.rb in mercenary-0.3.0
- old
+ new
@@ -11,42 +11,36 @@
def initialize(name)
@config = {}
super(name)
end
- # Public: Sets or gets the program version
- #
- # version - the program version (optional)
- #
- # Returns the version and sets it if an argument is present
- def version(version = nil)
- @version = version if version
- @version
- end
-
# Public: Run the program
#
- # argv - an array of string args (usually ARGV)
+ # argv - an array of string args (usually ARGV)
#
# Returns nothing
def go(argv)
logger.debug("Using args passed in: #{argv.inspect}")
cmd = nil
@optparse = OptionParser.new do |opts|
cmd = super(argv, opts, @config)
-
- opts.on('-v', '--version', 'Print the version') do
- puts "#{name} #{version}"
- abort
- end
end
@optparse.parse!(argv)
logger.debug("Parsed config: #{@config.inspect}")
- cmd.execute(argv, @config)
+ begin
+ cmd.execute(argv, @config)
+ rescue => e
+ if cmd.trace
+ raise e
+ else
+ logger.error e.message
+ abort
+ end
+ end
end
end
end