Class: Autoproj::CLI::Main
- Inherits:
-
Thor
- Object
- Thor
- Autoproj::CLI::Main
- Defined in:
- lib/autoproj/cli/main.rb
Class Attribute Summary collapse
-
.default_report_on_package_failures ⇒ Object
private
Override the CLI logic to determine what should be done on package failure (between raising or exiting).
Class Method Summary collapse
- .exit_on_failure? ⇒ Boolean
-
.register_post_command_hook(hook_name, &block) ⇒ Object
Register a hook that should be called at a given event.
-
.run_post_command_hook(hook_name, ws, **args) ⇒ Object
private
Run hooks defined for a given hook name.
Instance Method Summary collapse
- #bootstrap(*args) ⇒ Object
- #build(*packages) ⇒ Object
- #cache(*args) ⇒ Object
- #clean(*packages) ⇒ Object
- #commit(*packages) ⇒ Object
- #envsh ⇒ Object
- #exec(*args) ⇒ Object
- #install_stage2(root_dir, *vars) ⇒ Object
- #locate(*packages) ⇒ Object
- #log(*args) ⇒ Object
- #manifest(*name) ⇒ Object
- #osdeps(*packages) ⇒ Object
- #patch(*packages) ⇒ Object
- #query(query_string = nil) ⇒ Object
- #reconfigure ⇒ Object
- #reset(version_id) ⇒ Object
- #show(*packages) ⇒ Object
- #status(*packages) ⇒ Object
- #switch_config(*args) ⇒ Object
- #tag(tag_name = nil, *packages) ⇒ Object
- #unpatch(*packages) ⇒ Object
- #update(*packages) ⇒ Object
- #version(*args) ⇒ Object
- #versions(*packages) ⇒ Object
- #watch ⇒ Object
- #which(cmd) ⇒ Object
Class Attribute Details
.default_report_on_package_failures ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Override the CLI logic to determine what should be done on package failure (between raising or exiting)
This is used mainly in tests, to make sure that the CLI won’t be calling exit(). Set to nil to restore the default behavior
51 52 53 |
# File 'lib/autoproj/cli/main.rb', line 51 def default_report_on_package_failures @default_report_on_package_failures end |
Class Method Details
.exit_on_failure? ⇒ Boolean
39 40 41 |
# File 'lib/autoproj/cli/main.rb', line 39 def self.exit_on_failure? true end |
.register_post_command_hook(: update) {|ws, params| ... } ⇒ Object .register_post_command_hook(: build) {|ws, params| ... } ⇒ Object
Register a hook that should be called at a given event
86 87 88 |
# 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 |
.run_post_command_hook(hook_name, ws, **args) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Run hooks defined for a given hook name
57 58 59 60 61 |
# 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 |
Instance Method Details
#bootstrap(*args) ⇒ Object
154 155 156 157 158 159 160 161 162 163 |
# 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) = ops.( + args) ops.run exec Gem.ruby, $0, "bootstrap", * end run_autoproj_cli(:bootstrap, :Bootstrap, Hash[], *args) end |
#build(*packages) ⇒ Object
276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 |
# File 'lib/autoproj/cli/main.rb', line 276 def build(*packages) = Hash[silent: false, on_package_failures: default_report_on_package_failures] [:on_package_failures] = :report if [:auto_exclude] failures = run_autoproj_cli(:build, :Build, , *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 |
#cache(*args) ⇒ Object
332 333 334 |
# File 'lib/autoproj/cli/main.rb', line 332 def cache(*args) run_autoproj_cli(:cache, :Cache, Hash[], *args) end |
#clean(*packages) ⇒ Object
354 355 356 |
# File 'lib/autoproj/cli/main.rb', line 354 def clean(*packages) run_autoproj_cli(:clean, :Clean, Hash[], *packages) end |
#commit(*packages) ⇒ Object
499 500 501 |
# File 'lib/autoproj/cli/main.rb', line 499 def commit(*packages) run_autoproj_cli(:commit, :Commit, Hash[], *packages, deps: true) end |
#envsh ⇒ Object
166 167 168 |
# File 'lib/autoproj/cli/main.rb', line 166 def envsh run_autoproj_cli(:envsh, :Envsh, Hash[]) end |
#exec(*args) ⇒ Object
604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 |
# 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: [:debug], silent: true ) do opts = {} use_cache = [:use_cache] opts[:interactive] = [:interactive] opts[:chdir] = [:chdir] opts[:package] = [:package] opts[:use_cached_env] = use_cache unless use_cache.nil? CLI::Exec.new.run(*args, **opts) end end |
#install_stage2(root_dir, *vars) ⇒ Object
561 562 563 564 565 566 |
# 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.() ops.stage2(*vars) end |
#locate(*packages) ⇒ Object
367 368 369 |
# File 'lib/autoproj/cli/main.rb', line 367 def locate(*packages) run_autoproj_cli(:locate, :Locate, Hash[], *packages) end |
#log(*args) ⇒ Object
447 448 449 |
# File 'lib/autoproj/cli/main.rb', line 447 def log(*args) run_autoproj_cli(:log, :Log, Hash[], *args) end |
#manifest(*name) ⇒ Object
587 588 589 |
# File 'lib/autoproj/cli/main.rb', line 587 def manifest(*name) run_autoproj_cli(:manifest, :Manifest, Hash[silent: true], *name) end |
#osdeps(*packages) ⇒ Object
402 403 404 |
# File 'lib/autoproj/cli/main.rb', line 402 def osdeps(*packages) run_autoproj_cli(:osdeps, :OSDeps, Hash[silent: [:system_info]], *packages) end |
#patch(*packages) ⇒ Object
576 577 578 |
# File 'lib/autoproj/cli/main.rb', line 576 def patch(*packages) run_autoproj_cli(:patcher, :Patcher, Hash[], *packages, patch: true) end |
#query(query_string = nil) ⇒ Object
555 556 557 |
# File 'lib/autoproj/cli/main.rb', line 555 def query(query_string = nil) run_autoproj_cli(:query, :Query, Hash[], *Array(query_string)) end |
#reconfigure ⇒ Object
374 375 376 |
# File 'lib/autoproj/cli/main.rb', line 374 def reconfigure run_autoproj_cli(:reconfigure, :Reconfigure, Hash[]) end |
#reset(version_id) ⇒ Object
460 461 462 |
# File 'lib/autoproj/cli/main.rb', line 460 def reset(version_id) run_autoproj_cli(:reset, :Reset, Hash[], version_id) end |
#show(*packages) ⇒ Object
393 394 395 |
# File 'lib/autoproj/cli/main.rb', line 393 def show(*packages) run_autoproj_cli(:show, :Show, Hash[], *packages) end |
#status(*packages) ⇒ Object
190 191 192 |
# File 'lib/autoproj/cli/main.rb', line 190 def status(*packages) run_autoproj_cli(:status, :Status, Hash[], *packages) end |
#switch_config(*args) ⇒ Object
523 524 525 |
# File 'lib/autoproj/cli/main.rb', line 523 def switch_config(*args) run_autoproj_cli(:switch_config, :SwitchConfig, Hash[], *args) end |
#tag(tag_name = nil, *packages) ⇒ Object
478 479 480 |
# File 'lib/autoproj/cli/main.rb', line 478 def tag(tag_name = nil, *packages) run_autoproj_cli(:tag, :Tag, Hash[], tag_name, *packages) end |
#unpatch(*packages) ⇒ Object
582 583 584 |
# File 'lib/autoproj/cli/main.rb', line 582 def unpatch(*packages) run_autoproj_cli(:patcher, :Patcher, Hash[], *packages, patch: false) end |
#update(*packages) ⇒ Object
236 237 238 239 240 241 |
# File 'lib/autoproj/cli/main.rb', line 236 def update(*packages) = Hash[silent: false, on_package_failures: default_report_on_package_failures] [:on_package_failures] = :report if [:auto_exclude] run_autoproj_cli(:update, :Update, , *packages, run_hook: true) end |
#version(*args) ⇒ Object
409 410 411 |
# File 'lib/autoproj/cli/main.rb', line 409 def version(*args) run_autoproj_cli(:version, :Version, Hash[], *args) end |
#versions(*packages) ⇒ Object
437 438 439 |
# File 'lib/autoproj/cli/main.rb', line 437 def versions(*packages) run_autoproj_cli(:versions, :Versions, Hash[], *packages, deps: true) end |
#watch ⇒ Object
173 174 175 |
# File 'lib/autoproj/cli/main.rb', line 173 def watch run_autoproj_cli(:watch, :Watch, Hash[]) end |
#which(cmd) ⇒ Object
626 627 628 629 630 631 632 633 634 |
# 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: [:debug], silent: true) do opts = Hash.new use_cache = [:use_cache] opts[:use_cached_env] = use_cache unless use_cache.nil? CLI::Which.new.run(cmd, **opts) end end |