Skip to content

Commit f512400

Browse files
idodeclareVladimir Kotal
authored andcommitted
Fix up some help descriptions
1 parent cfbc0ba commit f512400

File tree

1 file changed

+61
-56
lines changed
  • opengrok-indexer/src/main/java/org/opengrok/indexer/index

1 file changed

+61
-56
lines changed

opengrok-indexer/src/main/java/org/opengrok/indexer/index/Indexer.java

Lines changed: 61 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -155,28 +155,7 @@ public static void main(String[] argv) {
155155
try {
156156
argv = parseOptions(argv);
157157
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();
180159
}
181160

182161
checkConfiguration();
@@ -467,16 +446,18 @@ public static String[] parseOptions(String[] argv) throws ParseException {
467446
});
468447

469448
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.",
475456
" Ex: -A .foo:CAnalyzer",
476457
" will use the C analyzer for all files ending with .FOO",
477458
" 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)",
480461
" Ex: -A .c:-",
481462
" will disable specialized analyzers for all files ending with .c").
482463
Do(analyzerSpec -> {
@@ -488,9 +469,8 @@ public static String[] parseOptions(String[] argv) throws ParseException {
488469
);
489470

490471
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)
494474
);
495475

496476
parser.on("--canonicalRoot", "=/path/",
@@ -507,7 +487,7 @@ public static String[] parseOptions(String[] argv) throws ParseException {
507487
});
508488

509489
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 -> {
511491
checkIndexVersion = true;
512492
});
513493

@@ -536,8 +516,8 @@ public static String[] parseOptions(String[] argv) throws ParseException {
536516
});
537517

538518
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.",
541521
" Ex: --disableRepository git",
542522
" will disable the GitRepository",
543523
" Ex: --disableRepository MercurialRepository").Do(v -> {
@@ -577,9 +557,8 @@ public static String[] parseOptions(String[] argv) throws ParseException {
577557
cfg.getIgnoredNames().add((String) pattern));
578558

579559
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 -> {
583562
try {
584563
if (v != null) {
585564
String vuc = v.toString().toUpperCase(Locale.ROOT);
@@ -592,7 +571,7 @@ public static String[] parseOptions(String[] argv) throws ParseException {
592571
});
593572

594573
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 -> {
596575
cfg.setAllowLeadingWildcard((Boolean) v);
597576
});
598577

@@ -619,7 +598,7 @@ public static String[] parseOptions(String[] argv) throws ParseException {
619598
parser.on("-N", "--symlink", "=/path/to/symlink",
620599
"Allow the symlink to be followed. Other symlinks targeting the same",
621600
"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",
623602
"directory are allowed. See also --canonicalRoot)").Do(v ->
624603
allowedSymlinks.add((String) v));
625604

@@ -629,8 +608,8 @@ public static String[] parseOptions(String[] argv) throws ParseException {
629608
runIndex = false);
630609

631610
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.").
634613
Do(v -> {
635614
boolean oldval = cfg.isOptimizeDatabase();
636615
cfg.setOptimizeDatabase((Boolean) v);
@@ -678,11 +657,11 @@ public static String[] parseOptions(String[] argv) throws ParseException {
678657
"Turn on/off quick context scan. By default, only the first 1024KB of a",
679658
"file is scanned, and a link ('[..all..]') is inserted when the file is",
680659
"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 ->
682661
cfg.setQuickContextScan((Boolean) v));
683662

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 -> {
686665
LoggerUtil.setBaseConsoleLogLevel(Level.WARNING);
687666
});
688667

@@ -716,7 +695,8 @@ public static String[] parseOptions(String[] argv) throws ParseException {
716695
parser.on("--renamedHistory", "=on|off", ON_OFF, Boolean.class,
717696
"Enable or disable generating history for renamed files.",
718697
"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));
720700

721701
parser.on("--repository", "=path/to/repository",
722702
"Path (relative to the source root) to a repository for generating",
@@ -755,16 +735,16 @@ public static String[] parseOptions(String[] argv) throws ParseException {
755735
cfg.setWebappLAF((String) stylePath));
756736

757737
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));
761741

762742
parser.on("-t", "--tabSize", "=number", Integer.class,
763743
"Default tab size to use (number of spaces per tab character).")
764744
.Do(tabSize -> cfg.setTabSize((Integer) tabSize));
765745

766746
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 -> {
768748
webappURI = (String) webAddr;
769749
try {
770750
URI uri = new URI(webappURI);
@@ -784,7 +764,7 @@ public static String[] parseOptions(String[] argv) throws ParseException {
784764
parser.on("---unitTest"); // For unit test only, will not appear in help
785765

786766
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 ->
788768
bareConfig = true);
789769

790770
parser.on("--userPage", "=URL",
@@ -807,9 +787,9 @@ public static String[] parseOptions(String[] argv) throws ParseException {
807787
});
808788

809789
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);
813793

814794
parser.on("--webappCtags", "=on|off", ON_OFF, Boolean.class,
815795
"Web application should run ctags when necessary. Default is off.").
@@ -837,11 +817,11 @@ private static void checkConfiguration() {
837817
env = RuntimeEnvironment.getInstance();
838818

839819
if (bareConfig && (env.getConfigURI() == null || env.getConfigURI().isEmpty())) {
840-
die("Missing webappURI URL");
820+
die("Missing webappURI setting");
841821
}
842822

843823
if (repositories.size() > 0 && !cfg.isHistoryEnabled()) {
844-
die("Repositories were specified however history is off");
824+
die("Repositories were specified; however history is off");
845825
}
846826
}
847827

@@ -1147,6 +1127,31 @@ private static void pauseToAwaitProfiler() {
11471127
}
11481128
}
11491129

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+
11501155
private static String getCtagsCommand() {
11511156
Ctags ctags = CtagsUtil.newInstance(env);
11521157
return Executor.escapeForShell(ctags.getArgv(), true, PlatformUtils.isWindows());

0 commit comments

Comments
 (0)