Class: BuildTool::Commands::Environments::List

Inherits:
Standard
  • Object
show all
Defined in:
lib/build-tool/commands/environments/list.rb

Overview

BuildCommand

Instance Attribute Summary

Attributes inherited from Base

#cmd, #options, #parent

Instance Method Summary collapse

Methods inherited from Standard

#complete_modules, #initialize, #log_directory, #while_logging_to

Methods inherited from Base

#<=>, #applicable?, #cleanup_after_vcs_access, #complete, #complete_arguments, #complete_readline_1_8, #complete_readline_1_9, #configuration, #do_complete_1_8, #do_complete_1_9, #each_option, #execute, #fullname, #initialize, #log?, #say, #setup_command, #show_help, #skip_command, #summarize, #teardown_command, #usage

Methods included from HelpText

#cmdalias, #description, included, #long_description, #name

Constructor Details

This class inherits a constructor from BuildTool::Commands::Standard

Instance Method Details

#do_execute(args) ⇒ Object



26
27
28
29
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
# File 'lib/build-tool/commands/environments/list.rb', line 26

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

#initialize_optionsObject



15
16
17
18
19
20
21
22
23
24
# File 'lib/build-tool/commands/environments/list.rb', line 15

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