lib/autoproj/cli/main.rb in autoproj-2.0.3 vs lib/autoproj/cli/main.rb in autoproj-2.1.0.rc1

- old
+ new

@@ -9,25 +9,20 @@ Encoding.default_internal = Encoding::UTF_8 Encoding.default_external = Encoding::UTF_8 end class Main < Thor - class_option :verbose, type: :boolean, - desc: 'turns verbose output', - default: false - class_option :debug, type: :boolean, - desc: 'turns debugging output', - default: false - class_option :silent, type: :boolean, - desc: 'tell autoproj to not display anything', - default: false - class_option :color, type: :boolean, - desc: 'enables or disables colored display (enabled by default if the terminal supports it)', - default: TTY::Color.color? - class_option :progress, type: :boolean, - desc: 'enables or disables progress display (enabled by default if the terminal supports it)', - default: TTY::Color.color? + class_option :verbose, type: :boolean, default: false, + desc: 'turns verbose output' + class_option :debug, type: :boolean, default: false, + desc: 'turns debugging output' + class_option :silent, type: :boolean, default: false, + desc: 'tell autoproj to not display anything' + class_option :color, type: :boolean, default: TTY::Color.color?, + desc: 'enables or disables colored display (enabled by default if the terminal supports it)' + class_option :progress, type: :boolean, default: TTY::Color.color?, + 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 @@ -36,22 +31,24 @@ # only_local if options.has_key?('local') options[:only_local] = options.delete('local') end cli = CLI.const_get(classname).new - run_args = cli.validate_options(args, options.merge(extra_options)) - cli.run(*run_args) + begin + run_args = cli.validate_options(args, options.merge(extra_options)) + cli.run(*run_args) + ensure + cli.notify_env_sh_updated + end end end end desc 'bootstrap VCS_TYPE VCS_URL VCS_OPTIONS', 'bootstraps a new autoproj installation. This is usually not called directly, but called from the autoproj_bootstrap standalone script' - option :reuse, - banner: 'DIR', + option :reuse, banner: 'DIR', desc: 'reuse packages already built within the DIR autoproj workspace in this installation, if DIR is not given, reuses the installation whose env.sh is currently sourced' - option :seed_config, - banner: 'SEED_CONFIG', + option :seed_config, banner: 'SEED_CONFIG', desc: "a configuration file used to seed the bootstrap's configuration" def bootstrap(*args) if !File.directory?(File.join(Dir.pwd, '.autoproj')) require 'autoproj/ops/install' ops = Autoproj::Ops::Install.new(Dir.pwd) @@ -74,49 +71,54 @@ 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 :snapshot, type: :boolean, default: false, desc: "use the VCS information as 'versions --no-local' would detect it instead of the one in the configuration" option :parallel, aliases: :p, type: :numeric, desc: 'maximum number of parallel jobs' - option :deps, type: :boolean, - desc: 'whether only the status of the given packages should be displayed, or of their dependencies as well', - default: true + option :deps, type: :boolean, default: true, + desc: 'whether only the status of the given packages should be displayed, or of their dependencies as well. -n is a shortcut for --no-deps' + option :no_deps_shortcut, hide: true, aliases: '-n', type: :boolean, + desc: 'provide -n for --no-deps' def status(*packages) run_autoproj_cli(:status, :Status, Hash[], *packages) end desc 'doc [PACKAGES]', 'generate API documentation for packages that support it' - option :deps, desc: 'control whether documentation should be generated only for the packages given on the command line, or also for their dependencies', - type: :boolean, default: true + option :deps, type: :boolean, default: true, + desc: 'control whether documentation should be generated only for the packages given on the command line, or also for their dependencies. -n is a shortcut for --no-deps' + option :no_deps_shortcut, hide: true, aliases: '-n', type: :boolean, + desc: 'provide -n for --no-deps' def doc(*packages) run_autoproj_cli(:doc, :Doc, Hash[], *packages) end desc 'update [PACKAGES]', 'update packages' option :aup, default: false, hide: true, type: :boolean, desc: 'behave like aup' option :all, default: false, hide: true, type: :boolean, desc: 'when in aup mode, update all packages instead of only the local one' - option :keep_going, aliases: :k, type: :boolean, - banner: '', + option :keep_going, aliases: :k, type: :boolean, banner: '', desc: 'do not stop on build or checkout errors' option :config, type: :boolean, desc: "(do not) update configuration. The default is to update configuration if explicitely selected or if no additional arguments are given on the command line, and to not do it if packages are explicitely selected on the command line" + option :bundler, type: :boolean, + desc: "(do not) update bundler. This is automatically enabled only if no arguments are given on the command line" option :autoproj, type: :boolean, desc: "(do not) update autoproj. This is automatically enabled only if no arguments are given on the command line" - option :osdeps, type: :boolean, - default: true, + option :osdeps, type: :boolean, default: true, desc: "enable or disable osdeps handling" option :from, type: :string, desc: 'use this existing autoproj installation to check out the packages (for importers that support this)' option :checkout_only, aliases: :c, type: :boolean, default: false, desc: "only checkout packages, do not update existing ones" option :local, type: :boolean, default: false, desc: "use only local information for the update (for importers that support it)" option :osdeps_filter_uptodate, default: true, type: :boolean, desc: 'controls whether the osdeps subsystem should filter up-to-date packages or not' option :deps, default: true, type: :boolean, - desc: 'whether the package dependencies should be recursively updated (the default) or not' + desc: 'whether the package dependencies should be recursively updated (the default) or not. -n is a shortcut for --no-deps' + option :no_deps_shortcut, hide: true, aliases: '-n', type: :boolean, + desc: 'provide -n for --no-deps' option :reset, default: false, type: :boolean, desc: "forcefully resets the repository to the state expected by autoproj's configuration", long_desc: "The default is to update the repository if possible, and leave it alone otherwise. With --reset, autoproj update might come back to an older commit than the repository's current state" option :force_reset, default: false, type: :boolean, desc: "like --reset, but bypasses tests that ensure you won't lose data" @@ -142,13 +144,22 @@ 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)' option :deps, type: :boolean, - desc: 'in force or rebuild modes, control whether the force/rebuild action should apply only on the packages given on the command line, or on their dependencies as well (the default is --no-deps)' + 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 +only on the packages given on the command line, or on their dependencies as well. +In this case, the default is false + EOD + option :no_deps_shortcut, hide: true, aliases: '-n', type: :boolean, + desc: 'provide -n for --no-deps' option :parallel, aliases: :p, type: :numeric, desc: 'maximum number of parallel jobs' + def build(*packages) run_autoproj_cli(:build, :Build, Hash[silent: false], *packages) end desc 'cache CACHE_DIR', 'create or update a cache directory that can be given to AUTOBUILD_CACHE_DIR' @@ -159,11 +170,26 @@ def cache(*cache_dir) run_autoproj_cli(:cache, :Cache, Hash[], *cache_dir) end desc 'clean [PACKAGES]', 'remove build byproducts for the given packages' - option :all, + long_desc <<-EODESC + Remove build byproducts from disk + + To avoid mistakes, 'clean' will ask for confirmation if no packages + are provided on the command line. Use --all to bypass this check (e.g. + in automated scripts) + + When packages are explicitely provided on the command line, autoproj + will by default not clean the package dependencies. However, when + no packages are provided on the command line, all the workspace + packages will be cleaned. Use --deps=f or --deps=t to override + these defaults. + EODESC + option :deps, type: :boolean, + desc: "clean the given packages as well as their dependencies" + option :all, type: :boolean, desc: 'bypass the safety question when you mean to clean all packages' def clean(*packages) run_autoproj_cli(:clean, :Clean, Hash[], *packages) end @@ -193,13 +219,14 @@ desc 'show [PACKAGES]', 'show informations about package(s)' 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 :env, type: :boolean, desc: "display the package's own environment", default: false - option :short, desc: 'display a package summary with one package line' - option :recursive, desc: 'display the package and their dependencies (the default is to only display selected packages)', - type: :boolean, default: false + option :short, + desc: 'display a package summary with one package line' + option :recursive, type: :boolean, default: false, + desc: 'display the package and their dependencies (the default is to only display selected packages)' def show(*packages) run_autoproj_cli(:show, :Show, Hash[], *packages) end desc 'osdeps [PACKAGES]', 'install/update OS dependencies that are required by the given package (or for the whole installation if no packages are given' @@ -208,39 +235,33 @@ def osdeps(*packages) run_autoproj_cli(:osdeps, :OSDeps, Hash[], *packages) end desc 'versions [PACKAGES]', 'generate a version file for the given packages, or all packages if none are given' - option :config, type: :boolean, - default: nil, - banner: '', + option :config, type: :boolean, default: nil, banner: '', desc: "controls whether the package sets should be versioned as well", long_desc: <<-EOD This is the default if no packages are given on the command line, or if the autoproj main configuration directory is. Note that if --config but no packages are given, the packages will not be versioned. In other words, autoproj versions # versions everything, configuration and packages autoproj versions --config # versions only the configuration autoproj versions autoproj/ # versions only the configuration autoproj versions autoproj a/package # versions the configuration and the specified package(s) EOD - option :keep_going, aliases: :k, type: :boolean, - default: false, - banner: '', + option :keep_going, aliases: :k, type: :boolean, default: false, banner: '', desc: 'do not stop if some package cannot be versioned' - option :replace, type: :boolean, - default: false, + option :replace, type: :boolean, default: false, desc: 'in combination with --save, controls whether an existing file should be updated or replaced' - option :deps, type: :boolean, - default: false, + option :deps, type: :boolean, default: false, desc: 'whether both packages and their dependencies should be versioned, or only the selected packages (the latter is the default)' option :local, type: :boolean, default: false, desc: 'whether we should access the remote server to verify that the snapshotted state is present' option :save, type: :string, desc: 'save to the given file instead of displaying it on the standard output' def versions(*packages) - run_autoproj_cli(:versions, :Versions, Hash[], *packages) + run_autoproj_cli(:versions, :Versions, Hash[], *packages, deps: true) end stop_on_unknown_option! :log desc 'log', "shows the log of autoproj updates" def log(*args) @@ -268,12 +289,11 @@ If given no arguments, will list the existing tags EOD option :package_sets, type: :boolean, desc: 'commit the package set state as well (enabled by default)' - option :keep_going, aliases: :k, type: :boolean, - banner: '', + option :keep_going, aliases: :k, type: :boolean, banner: '', desc: 'do not stop on build or checkout errors' option :message, aliases: :m, type: :string, desc: 'the message to use for the new commit (the default is to mention the creation of the tag)' def tag(tag_name = nil, *packages) run_autoproj_cli(:tag, :Tag, Hash[], tag_name, *packages) @@ -288,16 +308,15 @@ If given no arguments, will list the existing tags EOD option :package_sets, type: :boolean, desc: 'commit the package set state as well (enabled by default)' - option :keep_going, aliases: :k, type: :boolean, - banner: '', + option :keep_going, aliases: :k, type: :boolean, banner: '', desc: 'do not stop on build or checkout errors' option :message, aliases: :m, type: :string, desc: 'the message to use for the new commit (the default is to mention the creation of the tag)' def commit(*packages) - run_autoproj_cli(:commit, :Commit, Hash[], *packages) + run_autoproj_cli(:commit, :Commit, Hash[], *packages, deps: true) end desc 'switch-config VCS URL [OPTIONS]', 'switches the main build configuration' def switch_config(*args) run_autoproj_cli(:switch_config, :SwitchConfig, Hash[], *args)