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?, #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
#applicable? ⇒ Boolean
38 39 40 |
# File 'lib/build-tool/commands/features/list.rb', line 38 def applicable? BuildTool::Application.instance.has_recipe? end |
#do_execute(args) ⇒ Object
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 |
#initialize_options ⇒ Object
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 |
#list_features ⇒ Object
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 |
#show_feature(name) ⇒ Object
69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 |
# 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( "Name : %s" % feature.path ) 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 return 0 end |