Sha256: 88a26b19357dec62d81978db04b921d7e2d587e72ebed87b6dfa4a12c48d1dba

Contents?: true

Size: 1.75 KB

Versions: 2

Compression:

Stored size: 1.75 KB

Contents

require 'build-tool/commands'

module BuildTool; module Commands; module Modules

    #
    # BuildCommand
    #
    class List < Standard

        name        "list"
        description "list modules"
        long_description [ "Shows a list of modules. Without a parameter all modules are show. With",
                           "parameters list all modules matching them." ]
        cmdalias    "lsmods"

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

            @template = false
            @all = false

            @options.separator "Options:"

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

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

            super
        end

        def do_execute( args )
            # *TODO* listing local and remote recipes
            if args.length == 0
                configuration.modules.each do |mod|
                    if @template or not mod.is_template?
                        say "%-30s : %s" % [ mod.name, mod.description || "No description specified" ] if ( mod.active? || @all )
                    end
                end
            else
                args.each do |arg|
                    mods = complete_modules( arg, @template )
                    next if !mods
                    mods.each do |mod|
                        say "%-30s : %s" % [ mod.name, mod.description || "No description specified" ] if ( mod.active? || @all )
                    end
                end
            end

            return 0
        end

    end # class

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

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
build-tool-0.3.1 lib/build-tool/commands/modules/list.rb
build-tool-0.3 lib/build-tool/commands/modules/list.rb