public static void printOptions ( PrintStream out , String command , GroupedOptions ... groupings ) { out . println ( ) ; boolean firstRow = true ; for ( GroupedOptions grouping : groupings ) { if ( ! firstRow ) { out . println ( " OR " ) ; } firstRow = false ; StringBuilder sb = new StringBuilder ( "Usage: " + command ) ; for ( Option option : grouping . options ( ) ) { sb . append ( " " ) ; sb . append ( option . shortDisplay ( ) ) ; } out . println ( sb . toString ( ) ) ; } out . println ( ) ; final Set < Option > printed = new HashSet <> ( ) ; for ( GroupedOptions grouping : groupings ) { for ( Option option : grouping . options ( ) ) { if ( printed . add ( option ) ) { if ( option . longDisplay ( ) != null ) { out . println ( " " + option . longDisplay ( ) ) ; for ( String row : option . multiLineDisplay ( ) ) out . println ( " " + row ) ; } } } } }
pretty prints all of the option groupings