require 'build-tool/commands' module BuildTool; module Commands; # # BuildCommand # class Lsfeatures < Standard name "lsfeatures" description "List all available features." long_description [ "Shows the list of all features available with the current recipe or", "detailed info about one or more features given as arguments." ] def initialize_options @options.banner = "Usage: #{Pathname.new($0).basename} #{self.fullname} [FEATURES]..." super end def applicable? BuildTool::Application.instance.name != "build-tool" end 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 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 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 end # class Info end; end # module BuildTool::Commands