public String getTaskUsage ( ExeAction task ) { StringBuilder taskUsage = new StringBuilder ( NL ) ; // print a empty line taskUsage . append ( getHelpPart ( "global.usage" ) ) ; taskUsage . append ( NL ) ; taskUsage . append ( ' ' ) ; taskUsage . append ( COMMAND ) ; taskUsage . append ( ' ' ) ; taskUsage . append ( task ) ; taskUsage . append ( " [" ) ; taskUsage . append ( getHelpPart ( "global.options.lower" ) ) ; taskUsage . append ( "]" ) ; List < String > options = task . getCommandOptions ( ) ; for ( String option : options ) { if ( option . charAt ( 0 ) != ' ' ) { taskUsage . append ( ' ' ) ; taskUsage . append ( option ) ; } } taskUsage . append ( NL ) ; taskUsage . append ( NL ) ; taskUsage . append ( getHelpPart ( "global.description" ) ) ; taskUsage . append ( NL ) ; taskUsage . append ( getDescription ( task ) ) ; taskUsage . append ( NL ) ; if ( options . size ( ) > 0 ) { taskUsage . append ( NL ) ; taskUsage . append ( getHelpPart ( "global.options" ) ) ; for ( String option : task . getCommandOptions ( ) ) { taskUsage . append ( NL ) ; String optionKey ; try { optionKey = getHelpPart ( task + ".option-key." + option ) ; } catch ( MissingResourceException e ) { // This happens because we don't have a message for the key for the // license arguments but these are not translated and don't need any // arguments after them so can just use the option optionKey = " " + option ; } taskUsage . append ( optionKey ) ; taskUsage . append ( NL ) ; taskUsage . append ( getHelpPart ( task + ".option-desc." + option ) ) ; taskUsage . append ( NL ) ; } } taskUsage . append ( NL ) ; return taskUsage . toString ( ) ; }
Constructs a string to represent the usage for a particular task .