class Autoproj::CLI::Main
Attributes
Public Class Methods
Source
# File lib/autoproj/cli/main.rb, line 39 def self.exit_on_failure? true end
Source
# File lib/autoproj/cli/main.rb, line 86 def self.register_post_command_hook(hook_name, &block) @post_command_hooks[hook_name.to_sym] << block end
Register a hook that should be called at a given event
@overload register_post_command_hook
(:update)
@yieldparam [Workspace] ws @yieldparam [Hash] params Hook called after an update operation (from the CLI, either update or osdeps) The params contain :source_packages and :osdeps_packages, respectively the list of names of the source and osdeps packages selected for the update operation (NOT the list of packages actually updated)
@overload register_post_command_hook
(:build)
@yieldparam [Workspace] ws @yieldparam [Hash] params Hook called after a build operation (from the CLI, build) The params contain :source_packages, the list of names of the source and osdeps packages selected for the update operation (NOT the list of packages actually updated)
Source
# File lib/autoproj/cli/main.rb, line 57 def self.run_post_command_hook(hook_name, ws, **args) @post_command_hooks[hook_name].each do |hook| hook.call(ws, args) end end
@api private
Run hooks defined for a given hook name
Public Instance Methods
Source
# File lib/autoproj/cli/main.rb, line 154 def bootstrap(*args) unless File.directory?(File.join(Dir.pwd, ".autoproj")) require "autoproj/ops/install" ops = Autoproj::Ops::Install.new(Dir.pwd) bootstrap_options = ops.parse_options(thor_options_to_optparse + args) ops.run exec Gem.ruby, $0, "bootstrap", *bootstrap_options end run_autoproj_cli(:bootstrap, :Bootstrap, Hash[], *args) end
Source
# File lib/autoproj/cli/main.rb, line 276 def build(*packages) report_options = Hash[silent: false, on_package_failures: default_report_on_package_failures] report_options[:on_package_failures] = :report if options[:auto_exclude] failures = run_autoproj_cli(:build, :Build, report_options, *packages, tool_failure_mode: :report_silent) unless failures.empty? Autobuild.silent = false package_failures, config_failures = failures.partition do |e| e.respond_to?(:target) && e.target.respond_to?(:name) end packages_failed = package_failures .map do |e| if e.respond_to?(:target) && e.target.respond_to?(:name) e.target.name end end.compact unless packages_failed.empty? Autobuild.error "#{packages_failed.size} packages failed: #{packages_failed.sort.join(', ')}" end config_failures.each do |e| Autobuild.error(e) end exit 1 end end
Source
# File lib/autoproj/cli/main.rb, line 332 def cache(*args) run_autoproj_cli(:cache, :Cache, Hash[], *args) end
Source
# File lib/autoproj/cli/main.rb, line 354 def clean(*packages) run_autoproj_cli(:clean, :Clean, Hash[], *packages) end
Source
# File lib/autoproj/cli/main.rb, line 499 def commit(*packages) run_autoproj_cli(:commit, :Commit, Hash[], *packages, deps: true) end
Source
# File lib/autoproj/cli/main.rb, line 93 def default_report_on_package_failures if (override = Main.default_report_on_package_failures) override elsif options[:debug] :raise else :exit end end
Source
# File lib/autoproj/cli/main.rb, line 166 def envsh run_autoproj_cli(:envsh, :Envsh, Hash[]) end
Source
# File lib/autoproj/cli/main.rb, line 604 def exec(*args) require "autoproj/cli/exec" Autoproj.report( on_package_failures: default_report_on_package_failures, debug: options[:debug], silent: true ) do opts = {} use_cache = options[:use_cache] opts[:interactive] = options[:interactive] opts[:chdir] = options[:chdir] opts[:package] = options[:package] opts[:use_cached_env] = use_cache unless use_cache.nil? CLI::Exec.new.run(*args, **opts) end end
Source
# File lib/autoproj/cli/main.rb, line 561 def install_stage2(root_dir, *vars) require "autoproj/ops/install" ops = Autoproj::Ops::Install.new(root_dir) ops.parse_options(thor_options_to_optparse) ops.stage2(*vars) end
Source
# File lib/autoproj/cli/main.rb, line 367 def locate(*packages) run_autoproj_cli(:locate, :Locate, Hash[], *packages) end
Source
# File lib/autoproj/cli/main.rb, line 447 def log(*args) run_autoproj_cli(:log, :Log, Hash[], *args) end
Source
# File lib/autoproj/cli/main.rb, line 587 def manifest(*name) run_autoproj_cli(:manifest, :Manifest, Hash[silent: true], *name) end
Source
# File lib/autoproj/cli/main.rb, line 402 def osdeps(*packages) run_autoproj_cli(:osdeps, :OSDeps, Hash[silent: options[:system_info]], *packages) end
Source
# File lib/autoproj/cli/main.rb, line 576 def patch(*packages) run_autoproj_cli(:patcher, :Patcher, Hash[], *packages, patch: true) end
Source
# File lib/autoproj/cli/main.rb, line 555 def query(query_string = nil) run_autoproj_cli(:query, :Query, Hash[], *Array(query_string)) end
Source
# File lib/autoproj/cli/main.rb, line 374 def reconfigure run_autoproj_cli(:reconfigure, :Reconfigure, Hash[]) end
Source
# File lib/autoproj/cli/main.rb, line 460 def reset(version_id) run_autoproj_cli(:reset, :Reset, Hash[], version_id) end
Source
# File lib/autoproj/cli/main.rb, line 117 def run_autoproj_cli(filename, classname, report_options, *args, tool_failure_mode: :exit_silent, **extra_options) require "autoproj/cli/#{filename}" if options[:tool] Autobuild::Subprocess.transparent_mode = true Autobuild.silent = true Autobuild.color = false report_options[:silent] = true report_options[:on_package_failures] = tool_failure_mode 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") end cli = CLI.const_get(classname).new begin *run_args, kw = cli.validate_options(args, options.merge(extra_options)) kw = (kw || {}).transform_keys(&:to_sym) cli.run(*run_args, **kw) ensure if cli.respond_to?(:notify_env_sh_updated) cli.notify_env_sh_updated end end end end
Source
# File lib/autoproj/cli/main.rb, line 393 def show(*packages) run_autoproj_cli(:show, :Show, Hash[], *packages) end
Source
# File lib/autoproj/cli/main.rb, line 190 def status(*packages) run_autoproj_cli(:status, :Status, Hash[], *packages) end
Source
# File lib/autoproj/cli/main.rb, line 523 def switch_config(*args) run_autoproj_cli(:switch_config, :SwitchConfig, Hash[], *args) end
Source
# File lib/autoproj/cli/main.rb, line 478 def tag(tag_name = nil, *packages) run_autoproj_cli(:tag, :Tag, Hash[], tag_name, *packages) end
Source
# File lib/autoproj/cli/main.rb, line 106 def thor_options_to_optparse flags = [] %i[color progress debug interactive].each do |option| if options[option] then flags << "--#{option}" else flags << "--no-#{option}" end end flags end
Generate a command line for Ops::Install
, which has an internal option parser based on OptionParse (to be self-sufficient)
Source
# File lib/autoproj/cli/main.rb, line 582 def unpatch(*packages) run_autoproj_cli(:patcher, :Patcher, Hash[], *packages, patch: false) end
Source
# File lib/autoproj/cli/main.rb, line 236 def update(*packages) report_options = Hash[silent: false, on_package_failures: default_report_on_package_failures] report_options[:on_package_failures] = :report if options[:auto_exclude] run_autoproj_cli(:update, :Update, report_options, *packages, run_hook: true) end
Source
# File lib/autoproj/cli/main.rb, line 409 def version(*args) run_autoproj_cli(:version, :Version, Hash[], *args) end
Source
# File lib/autoproj/cli/main.rb, line 437 def versions(*packages) run_autoproj_cli(:versions, :Versions, Hash[], *packages, deps: true) end
Source
# File lib/autoproj/cli/main.rb, line 173 def watch run_autoproj_cli(:watch, :Watch, Hash[]) end
Source
# File lib/autoproj/cli/main.rb, line 626 def which(cmd) require "autoproj/cli/which" Autoproj.report(on_package_failures: default_report_on_package_failures, debug: options[:debug], silent: true) do opts = Hash.new use_cache = options[:use_cache] opts[:use_cached_env] = use_cache unless use_cache.nil? CLI::Which.new.run(cmd, **opts) end end