Class: Autoproj::CLI::SwitchConfig

Inherits:
Base
  • Object
show all
Defined in:
lib/autoproj/cli/switch_config.rb

Instance Attribute Summary

Attributes inherited from Base

#ws

Instance Method Summary collapse

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_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(args, options = Hash.new) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/autoproj/cli/switch_config.rb', line 10

def run(args, options = Hash.new)
    if !File.directory?(ws.config_dir)
        raise CLIInvalidArguments, "there's no autoproj/ directory in this workspace, use autoproj bootstrap to check out one"
    elsif Dir.pwd.start_with?(ws.remotes_dir) || Dir.pwd.start_with?(ws.config_dir)
        raise CLIInvalidArguments, "you cannot run autoproj switch-config from autoproj's configuration directory or one of its subdirectories"
    end

    ws.load_config
    ws.setup_os_package_installer

    # We must switch to the root dir first, as it is required by the
    # configuration switch code. This is acceptable as long as we
    # quit just after the switch
    switcher = Ops::MainConfigSwitcher.new(ws)
    if switcher.switch_config(*args)
        updater = Update.new(ws)
        updater.run([], config: true)
    end
end