@@ -155,28 +155,7 @@ public static void main(String[] argv) {
155
155
try {
156
156
argv = parseOptions (argv );
157
157
if (help ) {
158
- PrintStream helpStream = status != 0 ? System .err : System .out ;
159
- switch (helpMode ) {
160
- case CONFIG :
161
- helpStream .print (ConfigurationHelp .getSamples ());
162
- break ;
163
- case CTAGS :
164
- helpStream .println ("Ctags command-line:" );
165
- helpStream .println ();
166
- helpStream .println (getCtagsCommand ());
167
- helpStream .println ();
168
- break ;
169
- case GURU :
170
- helpStream .println (AnalyzerGuruHelp .getUsage ());
171
- break ;
172
- case REPOS :
173
- helpStream .println (RepositoriesHelp .getText ());
174
- break ;
175
- default :
176
- helpStream .println (helpUsage );
177
- break ;
178
- }
179
- System .exit (status );
158
+ exitWithHelp ();
180
159
}
181
160
182
161
checkConfiguration ();
@@ -467,16 +446,18 @@ public static String[] parseOptions(String[] argv) throws ParseException {
467
446
});
468
447
469
448
parser .on (
470
- "-A (.ext|prefix.):(-|analyzer)" , "--analyzer" , "/(\\ .\\ w+|\\ w+\\ .):(-|[a-zA-Z_0-9.]+)/" ,
471
- "Files with the named prefix/extension should be analyzed with the given" ,
472
- "analyzer, where 'analyzer' may be specified using a simple class name" ,
473
- "(e.g. RubyAnalyzer) or language name (e.g. C) and is case-sensitive." ,
474
- "Option may be repeated." ,
449
+ "-A (.ext|prefix.):(-|analyzer)" , "--analyzer" ,
450
+ "/(\\ .\\ w+|\\ w+\\ .):(-|[a-zA-Z_0-9.]+)/" ,
451
+ "Associates files with the specified prefix or extension (case-" ,
452
+ "insensitive) to be analyzed with the given analyzer, where 'analyzer'" ,
453
+ "may be specified using a simple class name (case-sensitive e.g." ,
454
+ "RubyAnalyzer) or language name (case-sensitive e.g. C) prefix. Option" ,
455
+ "may be repeated." ,
475
456
" Ex: -A .foo:CAnalyzer" ,
476
457
" will use the C analyzer for all files ending with .FOO" ,
477
458
" Ex: -A bar.:Perl" ,
478
- " will use the Perl analyzer for all files starting" ,
479
- " with \" BAR\" (no full-stop)" ,
459
+ " will use the Perl analyzer for all files starting with " ,
460
+ " \" BAR\" (no full-stop)" ,
480
461
" Ex: -A .c:-" ,
481
462
" will disable specialized analyzers for all files ending with .c" ).
482
463
Do (analyzerSpec -> {
@@ -488,9 +469,8 @@ public static String[] parseOptions(String[] argv) throws ParseException {
488
469
);
489
470
490
471
parser .on ("-c" , "--ctags" , "=/path/to/ctags" ,
491
- "Path to Universal Ctags" ,
492
- "By default takes the Universal Ctags in PATH." ).
493
- Do (ctagsPath -> cfg .setCtags ((String ) ctagsPath )
472
+ "Path to Universal Ctags. Default is ctags in PATH." ).Do (ctagsPath ->
473
+ cfg .setCtags ((String ) ctagsPath )
494
474
);
495
475
496
476
parser .on ("--canonicalRoot" , "=/path/" ,
@@ -507,7 +487,7 @@ public static String[] parseOptions(String[] argv) throws ParseException {
507
487
});
508
488
509
489
parser .on ("--checkIndexVersion" ,
510
- "Check if current Lucene version matches index version" ).Do (v -> {
490
+ "Check if current Lucene version matches index version. " ).Do (v -> {
511
491
checkIndexVersion = true ;
512
492
});
513
493
@@ -536,8 +516,8 @@ public static String[] parseOptions(String[] argv) throws ParseException {
536
516
});
537
517
538
518
parser .on ("--disableRepository" , "=type_name" ,
539
- "Disables operation of an OpenGrok-supported repository. Option may be " ,
540
- "repeated." ,
519
+ "Disables operation of an OpenGrok-supported repository. See also " ,
520
+ "-h,--help repos. Option may be repeated." ,
541
521
" Ex: --disableRepository git" ,
542
522
" will disable the GitRepository" ,
543
523
" Ex: --disableRepository MercurialRepository" ).Do (v -> {
@@ -577,9 +557,8 @@ public static String[] parseOptions(String[] argv) throws ParseException {
577
557
cfg .getIgnoredNames ().add ((String ) pattern ));
578
558
579
559
parser .on ("-l" , "--lock" , "=on|off|simple|native" , LUCENE_LOCKS ,
580
- "Set OpenGrok/Lucene locking mode of the Lucene database" ,
581
- "during index generation. \" on\" is an alias for \" simple\" ." ,
582
- "Default is off." ).Do (v -> {
560
+ "Set OpenGrok/Lucene locking mode of the Lucene database during index" ,
561
+ "generation. \" on\" is an alias for \" simple\" . Default is off." ).Do (v -> {
583
562
try {
584
563
if (v != null ) {
585
564
String vuc = v .toString ().toUpperCase (Locale .ROOT );
@@ -592,7 +571,7 @@ public static String[] parseOptions(String[] argv) throws ParseException {
592
571
});
593
572
594
573
parser .on ("--leadingWildCards" , "=on|off" , ON_OFF , Boolean .class ,
595
- "Allow or disallow leading wildcards in a search." ).Do (v -> {
574
+ "Allow or disallow leading wildcards in a search. Default is on. " ).Do (v -> {
596
575
cfg .setAllowLeadingWildcard ((Boolean ) v );
597
576
});
598
577
@@ -619,7 +598,7 @@ public static String[] parseOptions(String[] argv) throws ParseException {
619
598
parser .on ("-N" , "--symlink" , "=/path/to/symlink" ,
620
599
"Allow the symlink to be followed. Other symlinks targeting the same" ,
621
600
"canonical target or canonical children will be allowed too. Option may" ,
622
- "be repeated. (By default only symlinks directly under source root" ,
601
+ "be repeated. (By default only symlinks directly under the source root" ,
623
602
"directory are allowed. See also --canonicalRoot)" ).Do (v ->
624
603
allowedSymlinks .add ((String ) v ));
625
604
@@ -629,8 +608,8 @@ public static String[] parseOptions(String[] argv) throws ParseException {
629
608
runIndex = false );
630
609
631
610
parser .on ("-O" , "--optimize" , "=on|off" , ON_OFF , Boolean .class ,
632
- "Turn on/off the optimization of the index database" ,
633
- "as part of the indexing step." ).
611
+ "Turn on/off the optimization of the index database as part of the " ,
612
+ " indexing step. Default is on ." ).
634
613
Do (v -> {
635
614
boolean oldval = cfg .isOptimizeDatabase ();
636
615
cfg .setOptimizeDatabase ((Boolean ) v );
@@ -678,11 +657,11 @@ public static String[] parseOptions(String[] argv) throws ParseException {
678
657
"Turn on/off quick context scan. By default, only the first 1024KB of a" ,
679
658
"file is scanned, and a link ('[..all..]') is inserted when the file is" ,
680
659
"bigger. Activating this may slow the server down. (Note: this setting" ,
681
- "only affects the web application.)" ).Do (v ->
660
+ "only affects the web application.) Default is on. " ).Do (v ->
682
661
cfg .setQuickContextScan ((Boolean ) v ));
683
662
684
- parser .on ("-q" , "--quiet" , "Run as quietly as possible." ,
685
- "Sets logging level to WARNING." ).Do (v -> {
663
+ parser .on ("-q" , "--quiet" ,
664
+ "Run as quietly as possible. Sets logging level to WARNING." ).Do (v -> {
686
665
LoggerUtil .setBaseConsoleLogLevel (Level .WARNING );
687
666
});
688
667
@@ -716,7 +695,8 @@ public static String[] parseOptions(String[] argv) throws ParseException {
716
695
parser .on ("--renamedHistory" , "=on|off" , ON_OFF , Boolean .class ,
717
696
"Enable or disable generating history for renamed files." ,
718
697
"If set to on, makes history indexing slower for repositories" ,
719
- "with lots of renamed files." ).Do (v -> cfg .setHandleHistoryOfRenamedFiles ((Boolean ) v ));
698
+ "with lots of renamed files. Default is off." ).Do (v ->
699
+ cfg .setHandleHistoryOfRenamedFiles ((Boolean ) v ));
720
700
721
701
parser .on ("--repository" , "=path/to/repository" ,
722
702
"Path (relative to the source root) to a repository for generating" ,
@@ -755,16 +735,16 @@ public static String[] parseOptions(String[] argv) throws ParseException {
755
735
cfg .setWebappLAF ((String ) stylePath ));
756
736
757
737
parser .on ("-T" , "--threads" , "=number" , Integer .class ,
758
- "The number of threads to use for index generation." ,
759
- "By default the number of threads will be set to the number" ,
760
- "of available CPUs." ). Do ( threadCount -> cfg .setIndexingParallelism ((Integer ) threadCount ));
738
+ "The number of threads to use for index generation. By default the number " ,
739
+ " of threads will be set to the number of available CPUs." ). Do ( threadCount ->
740
+ cfg .setIndexingParallelism ((Integer ) threadCount ));
761
741
762
742
parser .on ("-t" , "--tabSize" , "=number" , Integer .class ,
763
743
"Default tab size to use (number of spaces per tab character)." )
764
744
.Do (tabSize -> cfg .setTabSize ((Integer ) tabSize ));
765
745
766
746
parser .on ("-U" , "--uri" , "=SCHEME://webappURI:port/contextPath" ,
767
- "Send the current configuration to the specified webappURI " ).Do (webAddr -> {
747
+ "Send the current configuration to the specified web application. " ).Do (webAddr -> {
768
748
webappURI = (String ) webAddr ;
769
749
try {
770
750
URI uri = new URI (webappURI );
@@ -784,7 +764,7 @@ public static String[] parseOptions(String[] argv) throws ParseException {
784
764
parser .on ("---unitTest" ); // For unit test only, will not appear in help
785
765
786
766
parser .on ("--updateConfig" ,
787
- "Populate the webapp with bare configuration, and exit." ).Do (v ->
767
+ "Populate the web application with a bare configuration, and exit." ).Do (v ->
788
768
bareConfig = true );
789
769
790
770
parser .on ("--userPage" , "=URL" ,
@@ -807,9 +787,9 @@ public static String[] parseOptions(String[] argv) throws ParseException {
807
787
});
808
788
809
789
parser .on ("-W" , "--writeConfig" , "=/path/to/configuration" ,
810
- "Write the current configuration to the specified file" ,
811
- "(so that the web application can use the same configuration)" )
812
- . Do ( configFile -> configFilename = (String ) configFile );
790
+ "Write the current configuration to the specified file (so that the web " ,
791
+ " application can use the same configuration)." ). Do ( configFile ->
792
+ configFilename = (String ) configFile );
813
793
814
794
parser .on ("--webappCtags" , "=on|off" , ON_OFF , Boolean .class ,
815
795
"Web application should run ctags when necessary. Default is off." ).
@@ -837,11 +817,11 @@ private static void checkConfiguration() {
837
817
env = RuntimeEnvironment .getInstance ();
838
818
839
819
if (bareConfig && (env .getConfigURI () == null || env .getConfigURI ().isEmpty ())) {
840
- die ("Missing webappURI URL " );
820
+ die ("Missing webappURI setting " );
841
821
}
842
822
843
823
if (repositories .size () > 0 && !cfg .isHistoryEnabled ()) {
844
- die ("Repositories were specified however history is off" );
824
+ die ("Repositories were specified; however history is off" );
845
825
}
846
826
}
847
827
@@ -1147,6 +1127,31 @@ private static void pauseToAwaitProfiler() {
1147
1127
}
1148
1128
}
1149
1129
1130
+ private static void exitWithHelp () {
1131
+ PrintStream helpStream = status != 0 ? System .err : System .out ;
1132
+ switch (helpMode ) {
1133
+ case CONFIG :
1134
+ helpStream .print (ConfigurationHelp .getSamples ());
1135
+ break ;
1136
+ case CTAGS :
1137
+ helpStream .println ("Ctags command-line:" );
1138
+ helpStream .println ();
1139
+ helpStream .println (getCtagsCommand ());
1140
+ helpStream .println ();
1141
+ break ;
1142
+ case GURU :
1143
+ helpStream .println (AnalyzerGuruHelp .getUsage ());
1144
+ break ;
1145
+ case REPOS :
1146
+ helpStream .println (RepositoriesHelp .getText ());
1147
+ break ;
1148
+ default :
1149
+ helpStream .println (helpUsage );
1150
+ break ;
1151
+ }
1152
+ System .exit (status );
1153
+ }
1154
+
1150
1155
private static String getCtagsCommand () {
1151
1156
Ctags ctags = CtagsUtil .newInstance (env );
1152
1157
return Executor .escapeForShell (ctags .getArgv (), true , PlatformUtils .isWindows ());
0 commit comments