Class: Autoproj::CLI::Clean

Inherits:
InspectionTool show all
Defined in:
lib/autoproj/cli/clean.rb

Instance Attribute Summary

Attributes inherited from Base

#ws

Instance Method Summary collapse

Methods inherited from InspectionTool

#finalize_setup, #initialize_and_load

Methods inherited from Base

#export_env_sh, #initialize, #normalize_command_line_package_selection, #notify_env_sh_updated, #resolve_selection, #resolve_user_selection, validate_options, #validate_user_selection

Methods included from Ops::Tools

#common_options, #create_autobuild_package, #load_autoprojrc, #load_main_initrb

Constructor Details

This class inherits a constructor from Autoproj::CLI::Base

Instance Method Details

#run(selection, options = Hash.new) ⇒ Object



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/autoproj/cli/clean.rb', line 18

def run(selection, options = Hash.new)
    initialize_and_load
    packages, = normalize_command_line_package_selection(selection)

    deps = if options.has_key?(:deps)
               options[:deps]
           else
               selection.empty?
           end

    source_packages, * = resolve_selection(
        packages,
        recursive: deps
    )
    if source_packages.empty?
        raise CLIInvalidArguments, "no packages or OS packages match #{selection.join(' ')}"
    end

    source_packages.each do |pkg_name|
        ws.manifest.find_autobuild_package(pkg_name)
          .prepare_for_rebuild
    end
end

#validate_options(packages, options) ⇒ Object



7
8
9
10
11
12
13
14
15
16
# File 'lib/autoproj/cli/clean.rb', line 7

def validate_options(packages, options)
    packages, options = super
    if packages.empty? && !options[:all]
        prompt = TTY::Prompt.new
        unless prompt.yes?("this is going to clean all packages. Is that really what you want ?")
            raise Interrupt
        end
    end
    [packages, options]
end