Sha256: 49c564808588cb0ea0b90863a9619d6e10d5821d30479e9bea993757894f1c6b

Contents?: true

Size: 1.92 KB

Versions: 16

Compression:

Stored size: 1.92 KB

Contents

require 'autoproj'
module Autoproj
    module CLI
        class Manifest
            attr_reader :ws

            def initialize(ws = Workspace.default)
                @ws = ws
            end

            def validate_options(args, options)
                return args, options
            end

            def run(name, options = Hash.new)
                ws.load_config
                if name.empty?
                    Autoproj.message "current manifest is #{ws.manifest_file_path}"
                elsif name.size == 1
                    name = name.first
                    if File.file?(full_path = File.expand_path(name))
                        if File.dirname(full_path) != ws.config_dir
                            raise ArgumentError, "#{full_path} is not part of #{ws.config_dir}"
                        end
                    else
                        full_path = File.join(ws.config_dir, name)
                    end

                    if !File.file?(full_path)
                        alternative_full_path = File.join(ws.config_dir, "manifest.#{name}")
                        if !File.file?(alternative_full_path)
                            raise ArgumentError, "neither #{full_path} nor #{alternative_full_path} exist"
                        end
                        full_path = alternative_full_path
                    end
                    begin
                        Autoproj::Manifest.new(ws).load(full_path)
                    rescue Exception
                        Autoproj.error "failed to load #{full_path}"
                        raise
                    end
                    ws.config.set 'manifest_name', File.basename(full_path)
                    ws.save_config
                    Autoproj.message "set manifest to #{full_path}"
                else
                    raise ArgumentError, "expected zero or one argument, but got #{name.size}"
                end
            end
        end
    end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
autoproj-2.3.0 lib/autoproj/cli/manifest.rb
autoproj-2.2.2 lib/autoproj/cli/manifest.rb
autoproj-2.2.1 lib/autoproj/cli/manifest.rb
autoproj-2.2.0 lib/autoproj/cli/manifest.rb
autoproj-2.1.2 lib/autoproj/cli/manifest.rb
autoproj-2.1.1 lib/autoproj/cli/manifest.rb
autoproj-2.1.0 lib/autoproj/cli/manifest.rb
autoproj-2.1.0.rc1 lib/autoproj/cli/manifest.rb
autoproj-2.0.3 lib/autoproj/cli/manifest.rb
autoproj-2.0.2 lib/autoproj/cli/manifest.rb
autoproj-2.0.1 lib/autoproj/cli/manifest.rb
autoproj-2.0.0 lib/autoproj/cli/manifest.rb
autoproj-2.0.0.rc42 lib/autoproj/cli/manifest.rb
autoproj-2.0.0.rc41 lib/autoproj/cli/manifest.rb
autoproj-2.0.0.rc40 lib/autoproj/cli/manifest.rb
autoproj-2.0.0.rc39 lib/autoproj/cli/manifest.rb