Class: BuildTool::Commands::Features::List
- Defined in:
- lib/build-tool/commands/features/list.rb
Overview
BuildCommand
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
- #applicable? ⇒ Boolean
- #do_execute(args) ⇒ Object
- #initialize_options ⇒ Object
- #list_features ⇒ Object
- #show_feature(name) ⇒ Object
Methods inherited from Standard
#complete_module, #complete_modules, #initialize, #log_directory, #while_logging_to
Methods inherited from Base
#<=>, #cleanup_after_vcs_access, #complete_arguments, #complete_readline, #configuration, #debug, #debug2, #do_complete, #each_option, #error, #execute, #fullname, #info, #initialize, #log?, #quiet, #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
permalink #applicable? ⇒ Boolean
38 39 40 |
# File 'lib/build-tool/commands/features/list.rb', line 38 def applicable? BuildTool::Application.instance.has_recipe? end |
permalink #do_execute(args) ⇒ Object
[View source]
42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/build-tool/commands/features/list.rb', line 42 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 |
permalink #initialize_options ⇒ Object
[View source]
26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/build-tool/commands/features/list.rb', line 26 def . = "Usage: #{self.fullname} [OPTIONS]... [FEATURES]..." .separator( "" ) .separator( "Options" ) .on( "--all", "Include inactive modules." ) { @all = true } super end |
permalink #list_features ⇒ Object
[View source]
55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/build-tool/commands/features/list.rb', line 55 def list_features features = configuration.features features.keys.sort.each do |name| feature = features[name] # skip inactive features if --all was not specified. next if not feature.active? and not @all # Skip feature without modules. next if feature.modules.empty? info( "%s %-30s : %s" % [ feature.active_char, name, feature.description ] ) end return 0 end |
permalink #show_feature(name) ⇒ Object
[View source]
69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 |
# File 'lib/build-tool/commands/features/list.rb', line 69 def show_feature( name ) feature = configuration.features[name] if feature.nil? error( "Unknown feature '%s'" % name ) return -1 end info( "%s : %s" % [ feature.path, feature.description ] ) if feature.parent info( "Active : %s (Parent %s: %s)" % [ feature.active_char, feature.parent.name, feature.parent.active_char ] ) else info( "Active : %s" % [ feature.active_char ] ) end info( "" ) if feature.long_description info( feature.long_description.sub( /^/, ' ' ) ) info( "" ) end subfeats = [] features = configuration.features features.keys.sort.each do |name| if name.start_with? feature.path next if name == feature.path subfeats << features[name] end end if not subfeats.empty? info( "Features" ) info( "====================================================" ) subfeats.each do |feat| info( "%s %-35s : %s" % [ feat.active_char, feat.path, feat.description || "No description specified" ] ) end info( "" ) end info( "Modules" ) info( "====================================================" ) feature.modules.each do |mod| next if mod.is_template? info( "%s%s %-35s : %s" % [ mod.active_char, mod.state_char, mod.name, mod.description || "No description specified" ] ) end info( "" ) return 0 end |