lib/autoproj/cli/main.rb in autoproj-2.2.2 vs lib/autoproj/cli/main.rb in autoproj-2.3.0

- old
+ new

@@ -23,11 +23,19 @@ desc: 'enables or disables progress display (enabled by default if the terminal supports it)' no_commands do def run_autoproj_cli(filename, classname, report_options, *args, **extra_options) require "autoproj/cli/#{filename}" - Autoproj.report(Hash[silent: !options[:debug], debug: options[:debug]].merge(report_options)) do + if Autobuild::Subprocess.transparent_mode = options[:tool] + Autobuild.silent = true + Autobuild.color = false + report_options[:silent] = true + report_options[:on_package_failures] = :exit_silent + extra_options[:silent] = true + end + + Autoproj.report(**Hash[silent: !options[:debug], debug: options[:debug]].merge(report_options)) do options = self.options.dup # We use --local on the CLI but the APIs are expecting # only_local if options.has_key?('local') options[:only_local] = options.delete('local') @@ -129,11 +137,16 @@ option :mainline, type: :string, desc: "compare to the given baseline. if 'true', the comparison will ignore any override, otherwise it will take into account overrides only up to the given package set" option :auto_exclude, type: :boolean, desc: 'if true, packages that fail to import will be excluded from the build' def update(*packages) - run_autoproj_cli(:update, :Update, Hash[silent: false], *packages) + report_options = Hash[silent: false, on_package_failures: :exit] + if options[:auto_exclude] + report_options[:on_package_failures] = :report + end + + run_autoproj_cli(:update, :Update, report_options, *packages) end desc 'build [PACKAGES]', 'build packages' option :amake, default: false, hide: true, type: :boolean, desc: 'behave like amake' @@ -144,11 +157,11 @@ option :force, type: :boolean, default: false, desc: 'force reconfiguration-build cycle on the requested packages, even if they do not seem to need it' option :rebuild, type: :boolean, default: false, desc: 'clean and build the requested packages' option :osdeps, type: :boolean, - desc: 'controls whether missing osdeps should be installed. In rebuild mode, also controls whether the osdeps should be reinstalled or not (the default is to reinstall them)' + desc: 'controls whether missing osdeps should be installed. In rebuild mode, also controls whether the osdeps should be reinstalled or not (the default is to reinstall them)' option :deps, type: :boolean, desc: "controls whether the operation should apply to the package's dependencies as well. -n is a shortcut for --no-deps", long_desc: <<-EOD Without --force or --rebuild, the default is true (the build will apply to all packages). With --force or --rebuild, control whether the force/rebuild action should apply @@ -159,12 +172,21 @@ desc: 'provide -n for --no-deps' option :parallel, aliases: :p, type: :numeric, desc: 'maximum number of parallel jobs' option :auto_exclude, type: :boolean, desc: 'if true, packages that fail to import will be excluded from the build' + option :tool, type: :boolean, + desc: "act as a build tool, transparently passing the subcommand's outputs to STDOUT" + option :confirm, type: :boolean, default: nil, + desc: '--force and --rebuild will ask confirmation if applied to the whole workspace. Use --no-confirm to disable this confirmation' def build(*packages) - run_autoproj_cli(:build, :Build, Hash[silent: false], *packages) + report_options = Hash[silent: false, on_package_failures: :exit] + if options[:auto_exclude] + report_options[:on_package_failures] = :report + end + + run_autoproj_cli(:build, :Build, Hash[silent: false].merge(report_options), *packages) end desc 'cache CACHE_DIR', 'create or update a cache directory that can be given to AUTOBUILD_CACHE_DIR' option :keep_going, aliases: :k, desc: 'do not stop on errors' @@ -266,11 +288,15 @@ def versions(*packages) run_autoproj_cli(:versions, :Versions, Hash[], *packages, deps: true) end stop_on_unknown_option! :log - desc 'log', "shows the log of autoproj updates" + desc 'log [REF]', "shows the log of autoproj updates" + option :since, type: :string, default: nil, + desc: 'show what got updated since the given version' + option :diff, type: :boolean, default: false, + desc: 'show the difference between two stages in the log' def log(*args) run_autoproj_cli(:log, :Log, Hash[], *args) end desc 'reset VERSION_ID', 'resets packages to the state stored in the required version' @@ -322,10 +348,29 @@ def commit(*packages) run_autoproj_cli(:commit, :Commit, Hash[], *packages, deps: true) end desc 'switch-config VCS URL [OPTIONS]', 'switches the main build configuration' + long_desc <<-EOD +Changes source of the main configuration that is checked out in autoproj/ + +For instance, + autoproj switch-config git http://github.com/rock-core/buildconf + +Options are of the form key=value. To for instance specify a git branch one does + autoproj switch-config git http://github.com/rock-core/buildconf branch=test + +The VCS types and options match the types and options available in the source.yml +files. + +If the URL is changed, autoproj will delete the existing autoproj folder. Alternatively, +when using a VCS that supports it (right now, git), it is possible to change a VCS +option without deleting the folder. Simply omit the VCS type and URL: + + autoproj switch-config branch=master + EOD + def switch_config(*args) run_autoproj_cli(:switch_config, :SwitchConfig, Hash[], *args) end desc 'query [QUERY]', 'searches for packages matching a query string. With no query string, matches all packages.' @@ -391,9 +436,14 @@ desc 'manifest', 'select or displays the active manifest' def manifest(*name) run_autoproj_cli(:manifest, :Manifest, Hash[silent: true], *name) end + + desc 'exec', "runs a command, applying the workspace's environment first" + def exec(*args) + require 'autoproj/cli/exec' + CLI::Exec.new.run(*args) + end end end end -