Skip to content

Commit

Permalink
Annotate more commands with binary output.
Browse files Browse the repository at this point in the history
Also do only strip ANSI escape codes if the corresponding output stream is not
marked as binary.

Previously, we have seen certain `cquery` and `aquery` invocations stripping
out "random" character sequences making it no longer parseable as proto.

PiperOrigin-RevId: 607287682
Change-Id: I5a4cf1322d6adeb65b6dcbec3a8b9681397dabe9
  • Loading branch information
meisterT authored and copybara-github committed Feb 15, 2024
1 parent 86312c0 commit d087622
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -461,11 +461,12 @@ private BlazeCommandResult execExclusively(
OutErr colorfulOutErr = outErr;

if (!eventHandlerOptions.useColor()) {
outErr = ansiStripOut(ansiStripErr(outErr));
if (!commandAnnotation.binaryStdOut()) {
outErr = ansiStripOut(outErr);
colorfulOutErr = ansiStripOut(colorfulOutErr);
}
if (!commandAnnotation.binaryStdErr()) {
outErr = ansiStripErr(outErr);
colorfulOutErr = ansiStripErr(colorfulOutErr);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
usesConfigurationOptions = true,
shortDescription = "Analyzes the given targets and queries the action graph.",
allowResidue = true,
binaryStdOut = true,
completion = "label",
help = "resource:aquery.txt")
public final class AqueryCommand implements BlazeCommand {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@
usesConfigurationOptions = true,
shortDescription = "Loads, analyzes, and queries the specified targets w/ configurations.",
allowResidue = true,
binaryStdOut = true,
completion = "label",
help = "resource:cquery.txt")
public final class CqueryCommand implements BlazeCommand {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,16 +59,17 @@

/** Implementation of the dump command. */
@Command(
mustRunInWorkspace = false,
options = {DumpCommand.DumpOptions.class},
help =
"Usage: %{product} dump <options>\n"
+ "Dumps the internal state of the %{product} server process. This command is provided "
+ "as an aid to debugging, not as a stable interface, so users should not try to "
+ "parse the output; instead, use 'query' or 'info' for this purpose.\n%{options}",
name = "dump",
shortDescription = "Dumps the internal state of the %{product} server process."
)
mustRunInWorkspace = false,
options = {DumpCommand.DumpOptions.class},
help =
"Usage: %{product} dump <options>\n"
+ "Dumps the internal state of the %{product} server process. This command is provided"
+ " as an aid to debugging, not as a stable interface, so users should not try to parse"
+ " the output; instead, use 'query' or 'info' for this purpose.\n"
+ "%{options}",
name = "dump",
shortDescription = "Dumps the internal state of the %{product} server process.",
binaryStdOut = true)
public class DumpCommand implements BlazeCommand {

/**
Expand Down

0 comments on commit d087622

Please sign in to comment.