Class: BuildTool::Commands::Modules::List

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

Overview

BuildCommand

Instance Attribute Summary

Attributes inherited from Base

#cmd, #options, #parent

Instance Method Summary collapse

Methods inherited from Standard

#complete_module, #complete_modules, #initialize, #log_directory, #while_logging_to

Methods inherited from Base

#<=>, #applicable?, #cleanup_after_vcs_access, #complete_arguments, #complete_readline, #configuration, #debug, #debug2, #do_complete, #each_option, #error, #execute, #fullname, #info, #initialize, #log?, #setup_command, #setup_options, #show_help, #skip_command, #summarize, #teardown_command, #trace, #usage, #verbose, #warn

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



68
69
70
71
72
73
74
75
76
77
78
79
80
81
# File 'lib/build-tool/commands/modules/list.rb', line 68

def do_execute( args )
    # *TODO* listing local and remote recipes
    if args.length == 0
        show_modules( configuration.modules )
    else
        args.each do |arg|
            mods = complete_modules( arg, @template )
            next if !mods
            show_modules( mods )
        end
    end

    return 0
end

#initialize_optionsObject



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
60
61
62
63
64
65
66
# File 'lib/build-tool/commands/modules/list.rb', line 31

def initialize_options
    options.banner = "Usage: #{self.fullname} [OPTIONS]... [MODULE|GROUP]..."
    options.separator( "" )
    options.separator( "Options" )

    @all = true

    @active = true
    @inactive = false
    options.on( "--all", "Include inactive modules." ) {
        @active = true
        @inactive = true
        }

    options.on( "--disabled", "Only show inactive modules." ) {
        @active = false
        @inactive = true
        }

    @template = false
    options.on( "--template", "Include template modules." ) {
        @template = true
        }

    @broken = false
    options.on( "--broken", "Show only broken modules." ) {
        @broken = true
        }

    @sort = true
    options.on( "--no-sort", "Show modules in order of declaration." ) {
        @sort = false
        }

    super
end

#show_module(mod) ⇒ Object



90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
# File 'lib/build-tool/commands/modules/list.rb', line 90

def show_module( mod )
    return if @broken         and not mod.broken?
    if mod.active?
        return if not @active
    else
        return if not @inactive
    end
    return if mod.is_template?   and not @template

    if @broken
        info( "%s%s %-35s : %-25s" % [ mod.active_char, mod.state_char, mod.name, mod.state ] )
    else
        info( "%s%s %-35s : %s" % [ mod.active_char, mod.state_char, mod.name,  mod.description || "No description specified" ] )
    end
end

#show_modules(mods) ⇒ Object



83
84
85
86
87
88
# File 'lib/build-tool/commands/modules/list.rb', line 83

def show_modules( mods )
    mods = mods.sort if @sort
    mods.each do |mod|
        show_module( mod )
    end
end