Class: Autoproj::CLI::MainPlugin

Inherits:
Thor
  • Object
show all
Defined in:
lib/autoproj/cli/main_plugin.rb

Instance Method Summary collapse

Instance Method Details

#install(name) ⇒ Object



37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# File 'lib/autoproj/cli/main_plugin.rb', line 37

def install(name)
    require "autoproj"

    gem_options = Hash.new
    if options[:git] && options[:path]
        raise CLIInvalidArguments, "you can provide only one of --git or --path"
    elsif options[:git]
        gem_options[:git] = options[:git]
        gem_options[:branch] = options[:branch]
    elsif options[:path]
        gem_options[:path] = options[:path]
    end

    plugins = read_plugin_list
    updated_plugins = plugins.merge(name => [options[:version], gem_options])
    write_plugin_list(updated_plugins)
    begin
        install_plugins
    rescue Exception
        write_plugin_list(plugins)
        install_plugins
        raise
    end
end

#listObject



63
64
65
66
67
68
69
# File 'lib/autoproj/cli/main_plugin.rb', line 63

def list
    require "autoproj"
    read_plugin_list.sort_by(&:first).each do |name, (version, options)|
        args = [version, *options.map { |k, v| "#{k}: \"#{v}\"" }]
        puts "#{name}: #{args.join(', ')}"
    end
end

#remove(name) ⇒ Object



72
73
74
75
76
77
78
79
# File 'lib/autoproj/cli/main_plugin.rb', line 72

def remove(name)
    require "autoproj"
    plugins = read_plugin_list
    updated_plugins = plugins.dup
    updated_plugins.delete(name)
    write_plugin_list(updated_plugins)
    install_plugins
end