Back to Bear

Command-line options

site/src/reference/command-line.md

4.2.03.9 KB
Original Source
<!-- Diataxis type: reference -->

Command-line options

bear runs in four modes, selected by the subcommand or its absence: combined (bear, no subcommand, the default), bear intercept, bear semantic, and bear parse-sh. Options given before -- belong to Bear; everything after -- is the build command, passed through untouched.

  • Combined runs the build, captures it, and writes the compilation database in one step. It is the default and the recommended way to run Bear.
  • bear intercept runs the build and only captures it, writing the raw event stream to a file for later analysis.
  • bear semantic reads an event stream and writes the compilation database, without running a build.
  • bear parse-sh writes the compilation database from shell command text, such as a build's dry-run output or a saved build log, without running anything.

See How Bear works for the mechanism behind capture and analysis, Configure Bear for every key the -c/--config file accepts, and Exit status for what Bear's own exit code means in each mode.

<!-- BEGIN GENERATED: scripts/generate-command-line-reference.py -- DO NOT EDIT. Edits inside this block are lost the next time the script runs. -->

Global usage

bear [OPTIONS] -- <BUILD_COMMAND>...
bear [OPTIONS] <COMMAND>

Bear is a tool that generates a compilation database for clang tooling.

Subcommands

CommandDescription
interceptintercepts command execution
semanticdetect semantics of command executions
parse-shproduces the compilation database from build-system dry-run text (e.g. make -n output)
helpPrint this message or the help of the given subcommand(s)

Arguments

ArgumentDescription
<BUILD_COMMAND>...Build command

Options

FlagDescriptionDefault
-c, --config <FILE>Path of the config file-
-o, --output <FILE>Path of the result filecompile_commands.json
-a, --appendAppend result to an existing output file-
-h, --helpPrint help-
-V, --versionPrint version-

bear intercept

intercepts command execution

bear intercept --output <FILE> -- <BUILD_COMMAND>...

Arguments

ArgumentDescription
<BUILD_COMMAND>...Build command

Options

FlagDescriptionDefault
-o, --output <FILE>Path of the event file to write-
-h, --helpPrint help-

bear semantic

detect semantics of command executions

bear semantic [OPTIONS]

Options

FlagDescriptionDefault
-i, --input <FILE>Path of the event file to read-
-o, --output <FILE>Path of the result filecompile_commands.json
-a, --appendAppend result to an existing output file-
--print-compilersPrint the compilers Bear recognizes and exit-
-h, --helpPrint help-

Reads the event stream that bear intercept (or a third-party producer) writes and produces the compilation database, e.g.:

sh
bear semantic --input events.json

bear parse-sh

produces the compilation database from build-system dry-run text (e.g. make -n output)

bear parse-sh [OPTIONS]

Options

FlagDescriptionDefault
-i, --input <FILE>Path of the shell text to parse-
-o, --output <FILE>Path of the result filecompile_commands.json
-a, --appendAppend result to an existing output file-
-C, --directory <DIR>Initial working directory for the parsed commands-
-h, --helpPrint help-

Parses the text a build system prints in dry-run mode and writes the compilation database, without running a build, e.g.:

sh
make -n | bear parse-sh
<!-- END GENERATED -->