Sha256: 0f89238481bded5b5b03b70595db5c8a48a6cbbb354e8bd4118eecb7ab4a7036

Contents?: true

Size: 1.82 KB

Versions: 15

Compression:

Stored size: 1.82 KB

Contents

require 'build-tool/commands'

module BuildTool; module Commands; module Environments

    #
    # BuildCommand
    #
    class List < Standard

        name        "list"
        description "List all available environments in alphabetical order."
        long_description [ "Shows the list of  all environments of the current recipe."]
        cmdalias    "lsenv"

        def initialize_options
            @options.banner = "Usage: #{Pathname.new($0).basename} #{self.fullname}"

            @options.separator "Options:"
            @all = false
            options.on( "--all", "Show inactive environments." ) { |t|
                @all = true
                }
                super
        end

        def do_execute( args )
            if args.length == 0

                say "%-15s (%s)" % [ "Environment", "Inherits" ]
                say "------------------------------------------------------------"
                configuration.environments.keys.sort.each do |name|
                    env = configuration.environment(name)
                    next if !env.active? && !@all
                    if env.parent
                        say "%-15s %s" % [ name, env.parent.name ]
                    else
                        say name
                    end
                end

            elsif args.length == 1

                say "Environment:"
                env = configuration.environment( args[ 0 ] )
                if env.parent
                    say "%-15s %s" % [ "Parent", env.parent.name ]
                end
                env.vars.sort.each do |var|
                    say "  %-20s %s" % [ var + ":", env[var] ]
                end

            else

                return usage( "To many arguments" )

            end

            return 0
        end

    end # class

end; end; end # module BuildTool::Commands::Modules


Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
build-tool-0.5.7 lib/build-tool/commands/environments/list.rb
build-tool-0.5.6 lib/build-tool/commands/environments/list.rb
build-tool-0.5.5 lib/build-tool/commands/environments/list.rb
build-tool-0.5.4 lib/build-tool/commands/environments/list.rb
build-tool-0.5.3 lib/build-tool/commands/environments/list.rb
build-tool-0.5.2 lib/build-tool/commands/environments/list.rb
build-tool-0.4.6 lib/build-tool/commands/environments/list.rb
build-tool-0.5.1 lib/build-tool/commands/environments/list.rb
build-tool-0.4.5 lib/build-tool/commands/environments/list.rb
build-tool-0.5.0 lib/build-tool/commands/environments/list.rb
build-tool-0.4.4 lib/build-tool/commands/environments/list.rb
build-tool-0.4.3 lib/build-tool/commands/environments/list.rb
build-tool-0.4.2 lib/build-tool/commands/environments/list.rb
build-tool-0.4.1 lib/build-tool/commands/environments/list.rb
build-tool-0.4.0 lib/build-tool/commands/environments/list.rb