public void printUsage ( Command command ) { String commandName = command . getDescriptor ( ) . getName ( ) ; StringBuilder sb = new StringBuilder ( getSyntaxPrefix ( ) ) . append ( commandName ) . append ( " " ) ; // create a list for processed option groups Collection < OptionGroup > processedGroups = new ArrayList <> ( ) ; Collection < Option > optList = command . getOptions ( ) . getAllOptions ( ) ; if ( optList . size ( ) > 1 && getOptionComparator ( ) != null ) { List < Option > optList2 = new ArrayList <> ( optList ) ; optList2 . sort ( getOptionComparator ( ) ) ; optList = optList2 ; } for ( Iterator < Option > it = optList . iterator ( ) ; it . hasNext ( ) ; ) { // get the next Option Option option = it . next ( ) ; // check if the option is part of an OptionGroup OptionGroup group = command . getOptions ( ) . getOptionGroup ( option ) ; if ( group != null ) { // if the group has not already been processed if ( ! processedGroups . contains ( group ) ) { // add the group to the processed list processedGroups . add ( group ) ; // add the usage clause appendOptionGroup ( sb , group ) ; } // otherwise the option was displayed in the group // previously so ignore it. } // if the Option is not part of an OptionGroup else { appendOption ( sb , option , option . isRequired ( ) ) ; } if ( it . hasNext ( ) ) { sb . append ( " " ) ; } } for ( Arguments arguments : command . getArgumentsList ( ) ) { sb . append ( " " ) ; appendArguments ( sb , arguments ) ; } printWrapped ( getSyntaxPrefix ( ) . length ( ) + commandName . length ( ) + 1 , sb . toString ( ) ) ; }
Prints the usage statement for the specified command .