Class: BuildTool::Commands::Lsfeatures

Inherits:
Standard show all
Defined in:
lib/build-tool/commands/lsfeatures.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

#<=>, #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

#applicable?Boolean

Returns:

  • (Boolean)


20
21
22
# File 'lib/build-tool/commands/lsfeatures.rb', line 20

def applicable?
    BuildTool::Application.instance.has_recipe?
end

#do_execute(args) ⇒ Object



24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/build-tool/commands/lsfeatures.rb', line 24

def do_execute( args )
    if args.length > 1
        # *TODO* print better message
        return usage "To many arguments."
    end

    if args.length == 1
        return show_feature( args[0] )
    else
        return list_features
    end
end

#initialize_optionsObject



15
16
17
18
# File 'lib/build-tool/commands/lsfeatures.rb', line 15

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

#list_featuresObject



37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/build-tool/commands/lsfeatures.rb', line 37

def list_features
    say "%-30s| %s | %s" % [ "Feature", "A", "Description" ]
    say "==========================================================="
    features = configuration.features
    features.keys.sort.each do |name|
        feature = features[name]
        # Skip feature without modules
        next if feature.modules.empty?
        active = "N"
        active = "Y" if feature.active?
        say "%-30s| %s | %s" % [ name, active, feature.description ]
    end

    return 0
end

#show_feature(name) ⇒ Object



53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# File 'lib/build-tool/commands/lsfeatures.rb', line 53

def show_feature( name )
    feature = configuration.features[name]

    if feature.nil?
        logger.error( "Unknown feature '%s'" % name )
        return -1
    end

    say "Name    : %s" % feature.path
    say "Modules"
    say "===================================================="
    feature.modules.each do |mod|
        next if mod.is_template?
        say "  %-20s: %s" % [ mod.name, mod.description ]
    end
    return 0
end