Class: Autoproj::CLI::Versions

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

Constant Summary collapse

DEFAULT_VERSIONS_FILE_BASENAME =
Ops::Snapshot::DEFAULT_VERSIONS_FILE_BASENAME

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

#default_versions_fileObject



11
12
13
# File 'lib/autoproj/cli/versions.rb', line 11

def default_versions_file
    File.join(ws.overrides_dir, DEFAULT_VERSIONS_FILE_BASENAME)
end

#run(user_selection, options) ⇒ Object



30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# File 'lib/autoproj/cli/versions.rb', line 30

def run(user_selection, options)
    initialize_and_load
    packages, *, config_selected =
        finalize_setup(user_selection,
                       recursive: options[:deps])

    ops = Ops::Snapshot.new(ws.manifest, keep_going: options[:keep_going])

    if user_selection.empty?
        snapshot_package_sets = (options[:config] != false)
        snapshot_packages = !options[:config]
    elsif config_selected
        snapshot_package_sets = true
        snapshot_packages = user_selection.size > 1
    else
        snapshot_package_sets = options[:config]
        snapshot_packages = true
    end

    versions = Array.new
    if snapshot_package_sets
        versions += ops.snapshot_package_sets(nil, only_local: options[:only_local])
    end
    if snapshot_packages
        versions += ops.snapshot_packages(packages,
                                          nil,
                                          only_local: options[:only_local],
                                          fingerprint: options[:fingerprint])
    end

    if (output_file = options[:save])
        ops.save_versions(versions, output_file, replace: options[:replace])
    else
        versions = ops.sort_versions(versions)
        puts YAML.dump(versions)
    end
end

#validate_options(packages, options = Hash.new) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/autoproj/cli/versions.rb', line 15

def validate_options(packages, options = Hash.new)
    packages, options = super
    unless options[:save].nil?
        options[:save] = case options[:save]
                         when "."
                             nil
                         when "save"
                             default_versions_file
                         else
                             options[:save].to_str
                         end
    end
    [packages, options]
end