bin/amake in autoproj-1.7.8 vs bin/amake in autoproj-1.7.9

- old
+ new

@@ -1,8 +1,56 @@ #! /usr/bin/env ruby -if ARGV.grep(/^-/).size == ARGV.size - ARGV.push '.' +require 'optparse' + +build_all = false +force = false + +parser = OptionParser.new do |opt| + opt.banner = "amake [options] [dir_or_package] +Runs autoproj build for the given directory or package name. +Selects the current directory if none is given + +Accepts all options from autoproj build plus the following options: + +" + opt.on('--all', 'runs autoproj build without arguments (does not add the current directory)') do + build_all = true + end + opt.on('--force', 'runs autoproj force-build instead of autoproj build') do + force = true + end + opt.on('--help', 'shows this help message') do + puts parser + exit(0) + end end -ARGV.unshift "build" + +# Accept options that are invalid in +parser+, to pass them on to autoproj +# itself +options = ARGV.dup +remaining = [] +while !options.empty? + begin + head = options.shift + remaining.concat(parser.parse([head])) + rescue OptionParser::InvalidOption + remaining << head + retry + end +end + +# If --all is not given *and* there is no non-option argument (i.e. no directory +# / package name), add the current directory to the command line +if remaining.grep(/^-/).size == remaining.size && !build_all + remaining.push '.' +end + +if force + remaining.unshift "force-build" +else + remaining.unshift "build" +end +ARGV.clear +ARGV.concat(remaining) load File.expand_path('autoproj', File.dirname(__FILE__))