@ Override public String usage ( final boolean printCommon , final boolean printHidden ) { final StringBuilder sb = new StringBuilder ( ) ; if ( ! printHidden ) { logger . warn ( "Hidden arguments are always printed in LegacyCommandLineArgumentParser" ) ; } if ( prefix . isEmpty ( ) ) { final String preamble = htmlUnescape ( convertFromHtml ( getStandardUsagePreamble ( callerOptions . getClass ( ) ) + getUsagePreamble ( ) ) ) ; checkForNonASCII ( preamble , "Tool description" ) ; sb . append ( Utils . wrapParagraph ( preamble , OPTION_COLUMN_WIDTH + DESCRIPTION_COLUMN_WIDTH ) ) ; sb . append ( "\nVersion: " + getVersion ( ) ) ; sb . append ( "\n" ) ; sb . append ( "\n\nOptions:\n\n" ) ; for ( final String [ ] optionDoc : FRAMEWORK_OPTION_DOC ) { printOptionParamUsage ( sb , optionDoc [ 0 ] , optionDoc [ 1 ] , null , optionDoc [ 2 ] ) ; } } if ( ! optionDefinitions . isEmpty ( ) ) { optionDefinitions . stream ( ) . filter ( optionDefinition -> printCommon || ! optionDefinition . isCommon ) . forEach ( optionDefinition -> printOptionUsage ( sb , optionDefinition ) ) ; } if ( printCommon ) { final Field fileField ; try { //Temp class OPTIONS_FILE class OptionFileContainerForUsage { public File optionFileContainer ; } fileField = OptionFileContainerForUsage . class . getField ( "optionFileContainer" ) ; } catch ( final NoSuchFieldException e ) { throw new CommandLineException ( "Should never happen" , e ) ; } final OptionDefinition optionsFileOptionDefinition = new OptionDefinition ( fileField , null , OPTIONS_FILE , "" , "File of OPTION_NAME=value pairs. No positional parameters allowed. Unlike command-line options, " + "unrecognized options are ignored. " + "A single-valued option set in an options file may be overridden " + "by a subsequent command-line option. " + "A line starting with '#' is considered a comment." , false , false , 0 , Integer . MAX_VALUE , null , true , new String [ 0 ] ) ; printOptionUsage ( sb , optionsFileOptionDefinition ) ; } return sb . toString ( ) ; }
Print a usage message based on the options object passed to the ctor .