aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/java/com/google/devtools/build/lib/runtime/commands/HelpCommand.java
diff options
context:
space:
mode:
authorGravatar ccalvarin <ccalvarin@google.com>2018-03-27 13:38:15 -0700
committerGravatar Copybara-Service <copybara-piper@google.com>2018-03-27 13:39:47 -0700
commit8bbb6c23d25b85fe13b41edd16010c2b5fafe2ea (patch)
tree590ce8e4b0d5583d8cf4cbdf084d75afc8b87b95 /src/main/java/com/google/devtools/build/lib/runtime/commands/HelpCommand.java
parent57203631fe71a7bebc8fb16b2d0f38fee8cc5139 (diff)
Remove old option categorization from the help output.
In preparation for removing all uses of the category field in Bazel options. RELNOTES: None. PiperOrigin-RevId: 190665669
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/runtime/commands/HelpCommand.java')
-rw-r--r--src/main/java/com/google/devtools/build/lib/runtime/commands/HelpCommand.java133
1 files changed, 17 insertions, 116 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/runtime/commands/HelpCommand.java b/src/main/java/com/google/devtools/build/lib/runtime/commands/HelpCommand.java
index 6f47e3d1fb..4de7cbf5f8 100644
--- a/src/main/java/com/google/devtools/build/lib/runtime/commands/HelpCommand.java
+++ b/src/main/java/com/google/devtools/build/lib/runtime/commands/HelpCommand.java
@@ -48,6 +48,7 @@ import com.google.devtools.common.options.OptionFilterDescriptions;
import com.google.devtools.common.options.OptionMetadataTag;
import com.google.devtools.common.options.OptionsBase;
import com.google.devtools.common.options.OptionsParser;
+import com.google.devtools.common.options.OptionsParser.HelpVerbosity;
import com.google.devtools.common.options.OptionsProvider;
import java.util.ArrayList;
import java.util.Base64;
@@ -85,11 +86,10 @@ public final class HelpCommand implements BlazeCommand {
@Option(
name = "help_verbosity",
- category = "help",
defaultValue = "medium",
converter = Converters.HelpVerbosityConverter.class,
- documentationCategory = OptionDocumentationCategory.LOGGING,
- effectTags = {OptionEffectTag.AFFECTS_OUTPUTS, OptionEffectTag.TERMINAL_OUTPUT},
+ documentationCategory = OptionDocumentationCategory.LOGGING,
+ effectTags = {OptionEffectTag.AFFECTS_OUTPUTS, OptionEffectTag.TERMINAL_OUTPUT},
help = "Select the verbosity of the help command."
)
public OptionsParser.HelpVerbosity helpVerbosity;
@@ -98,10 +98,9 @@ public final class HelpCommand implements BlazeCommand {
name = "long",
abbrev = 'l',
defaultValue = "null",
- category = "help",
expansion = {"--help_verbosity=long"},
- documentationCategory = OptionDocumentationCategory.LOGGING,
- effectTags = {OptionEffectTag.AFFECTS_OUTPUTS, OptionEffectTag.TERMINAL_OUTPUT},
+ documentationCategory = OptionDocumentationCategory.LOGGING,
+ effectTags = {OptionEffectTag.AFFECTS_OUTPUTS, OptionEffectTag.TERMINAL_OUTPUT},
help = "Show full description of each option, instead of just its name."
)
public Void showLongFormOptions;
@@ -109,68 +108,12 @@ public final class HelpCommand implements BlazeCommand {
@Option(
name = "short",
defaultValue = "null",
- category = "help",
expansion = {"--help_verbosity=short"},
- documentationCategory = OptionDocumentationCategory.LOGGING,
- effectTags = {OptionEffectTag.AFFECTS_OUTPUTS, OptionEffectTag.TERMINAL_OUTPUT},
- help = "Show only the names of the options, not their types or meanings."
- )
- public Void showShortFormOptions;
-
- @Option(
- name = "use_new_category_enum",
- defaultValue = "true",
documentationCategory = OptionDocumentationCategory.LOGGING,
effectTags = {OptionEffectTag.AFFECTS_OUTPUTS, OptionEffectTag.TERMINAL_OUTPUT},
- metadataTags = {OptionMetadataTag.EXPERIMENTAL}
+ help = "Show only the names of the options, not their types or meanings."
)
- public boolean useNewCategoryEnum;
- }
-
- /**
- * Returns a map that maps option categories to descriptive help strings for categories that are
- * not part of the Bazel core.
- */
- @Deprecated
- private static ImmutableMap<String, String> getDeprecatedOptionCategoriesDescriptions(
- String name) {
- ImmutableMap.Builder<String, String> optionCategoriesBuilder = ImmutableMap.builder();
- optionCategoriesBuilder
- .put("checking", String.format(
- "Checking options, which control %s's error checking and/or warnings", name))
- .put("coverage", String.format(
- "Options that affect how %s generates code coverage information", name))
- .put("experimental",
- "Experimental options, which control experimental (and potentially risky) features")
- .put("flags",
- "Flags options, for passing options to other tools")
- .put("help",
- "Help options")
- .put("host jvm startup", String.format(
- "Options that affect the startup of the %s server's JVM", name))
- .put("misc",
- "Miscellaneous options")
- .put("package loading",
- "Options that specify how to locate packages")
- .put("query", String.format(
- "Options affecting the '%s query' dependency query command", name))
- .put("run", String.format(
- "Options specific to '%s run'", name))
- .put("semantics",
- "Semantics options, which affect the build commands and/or output file contents")
- .put("server startup", String.format(
- "Startup options, which affect the startup of the %s server", name))
- .put("strategy", String.format(
- "Strategy options, which affect how %s will execute the build", name))
- .put("testing", String.format(
- "Options that affect how %s runs tests", name))
- .put("verbosity", String.format(
- "Verbosity options, which control what %s prints", name))
- .put("version",
- "Version options, for selecting which version of other tools will be used")
- .put("what",
- "Output selection options, for determining what to build/test");
- return optionCategoriesBuilder.build();
+ public Void showShortFormOptions;
}
@Override
@@ -198,20 +141,11 @@ public final class HelpCommand implements BlazeCommand {
switch (helpSubject) {
case "startup_options":
emitBlazeVersionInfo(outErr, runtime.getProductName());
- emitStartupOptions(
- outErr,
- helpOptions.helpVerbosity,
- runtime,
- getDeprecatedOptionCategoriesDescriptions(productName),
- helpOptions.useNewCategoryEnum);
+ emitStartupOptions(outErr, helpOptions.helpVerbosity, runtime);
return BlazeCommandResult.exitCode(ExitCode.SUCCESS);
case "target-syntax":
emitBlazeVersionInfo(outErr, runtime.getProductName());
- emitTargetSyntaxHelp(
- outErr,
- getDeprecatedOptionCategoriesDescriptions(productName),
- productName,
- helpOptions.useNewCategoryEnum);
+ emitTargetSyntaxHelp(outErr, productName);
return BlazeCommandResult.exitCode(ExitCode.SUCCESS);
case "info-keys":
@@ -224,7 +158,7 @@ public final class HelpCommand implements BlazeCommand {
emitFlagsAsProtoHelp(runtime, outErr);
return BlazeCommandResult.exitCode(ExitCode.SUCCESS);
case "everything-as-html":
- new HtmlEmitter(runtime, helpOptions.useNewCategoryEnum).emit(outErr);
+ new HtmlEmitter(runtime).emit(outErr);
return BlazeCommandResult.exitCode(ExitCode.SUCCESS);
default: // fall out
}
@@ -248,12 +182,10 @@ public final class HelpCommand implements BlazeCommand {
outErr.printOut(
BlazeCommandUtils.getUsage(
command.getClass(),
- getDeprecatedOptionCategoriesDescriptions(productName),
helpOptions.helpVerbosity,
runtime.getBlazeModules(),
runtime.getRuleClassProvider(),
- productName,
- helpOptions.useNewCategoryEnum));
+ productName));
return BlazeCommandResult.exitCode(ExitCode.SUCCESS);
}
@@ -265,21 +197,15 @@ public final class HelpCommand implements BlazeCommand {
}
private void emitStartupOptions(
- OutErr outErr,
- OptionsParser.HelpVerbosity helpVerbosity,
- BlazeRuntime runtime,
- ImmutableMap<String, String> optionCategories,
- boolean useNewCategoryEnum) {
+ OutErr outErr, HelpVerbosity helpVerbosity, BlazeRuntime runtime) {
outErr.printOut(
BlazeCommandUtils.expandHelpTopic(
"startup_options",
"resource:startup_options.txt",
getClass(),
BlazeCommandUtils.getStartupOptions(runtime.getBlazeModules()),
- optionCategories,
helpVerbosity,
- runtime.getProductName(),
- useNewCategoryEnum));
+ runtime.getProductName()));
}
private void emitCompletionHelp(BlazeRuntime runtime, OutErr outErr) {
@@ -380,21 +306,15 @@ public final class HelpCommand implements BlazeCommand {
return ImmutableSortedMap.copyOf(runtime.getCommandMap());
}
- private void emitTargetSyntaxHelp(
- OutErr outErr,
- ImmutableMap<String, String> optionCategories,
- String productName,
- boolean useNewCategoryEnum) {
+ private void emitTargetSyntaxHelp(OutErr outErr, String productName) {
outErr.printOut(
BlazeCommandUtils.expandHelpTopic(
"target-syntax",
"resource:target-syntax.txt",
getClass(),
ImmutableList.<Class<? extends OptionsBase>>of(),
- optionCategories,
OptionsParser.HelpVerbosity.MEDIUM,
- productName,
- useNewCategoryEnum));
+ productName));
}
private void emitInfoKeysHelp(CommandEnvironment env, OutErr outErr) {
@@ -441,19 +361,9 @@ public final class HelpCommand implements BlazeCommand {
private static final class HtmlEmitter {
private final BlazeRuntime runtime;
- private final ImmutableMap<String, String> deprecatedOptionCategoryDescriptions;
- private final boolean useNewCategoriesEnum;
- private HtmlEmitter(BlazeRuntime runtime, boolean useNewCategoriesEnum) {
+ private HtmlEmitter(BlazeRuntime runtime) {
this.runtime = runtime;
- this.useNewCategoriesEnum = useNewCategoriesEnum;
- String productName = runtime.getProductName();
- if (useNewCategoriesEnum) {
- this.deprecatedOptionCategoryDescriptions = null;
- } else {
- this.deprecatedOptionCategoryDescriptions =
- getDeprecatedOptionCategoriesDescriptions(productName);
- }
}
private void emit(OutErr outErr) {
@@ -529,7 +439,6 @@ public final class HelpCommand implements BlazeCommand {
}
// Describe the tags once, any mentions above should link to these descriptions.
- if (useNewCategoriesEnum) {
String productName = runtime.getProductName();
ImmutableMap<OptionEffectTag, String> effectTagDescriptions =
OptionFilterDescriptions.getOptionEffectTagDescription(productName);
@@ -567,7 +476,7 @@ public final class HelpCommand implements BlazeCommand {
}
}
result.append("</table>\n");
- }
+
outErr.printOut(result.toString());
}
@@ -576,18 +485,10 @@ public final class HelpCommand implements BlazeCommand {
StringBuilder result, Iterable<Class<? extends OptionsBase>> optionsClasses) {
OptionsParser parser = OptionsParser.newOptionsParser(optionsClasses);
String productName = runtime.getProductName();
- if (useNewCategoriesEnum) {
result.append(
parser
.describeOptionsHtml(HTML_ESCAPER, productName)
.replace("%{product}", productName));
- } else {
- result.append(
- parser
- .describeOptionsHtmlWithDeprecatedCategories(
- deprecatedOptionCategoryDescriptions, HTML_ESCAPER)
- .replace("%{product}", productName));
- }
}
private static String capitalize(String s) {