2020-11-19 20:01:02 +00:00
# `src search`
## Flags
| Name | Description | Default Value |
|------|-------------|---------------|
2021-03-10 20:56:48 +00:00
| `-display` | Limit the number of results that are displayed. Only supported together with stream flag. Statistics continue to report all results. | `-1` |
2020-11-19 20:01:02 +00:00
| `-dump-requests` | Log GraphQL requests and responses to stdout | `false` |
| `-explain-json` | Explain the JSON output schema and exit. | `false` |
| `-get-curl` | Print the curl command for executing this query and exit (WARNING: includes printing your access token!) | `false` |
2021-03-10 20:56:48 +00:00
| `-insecure-skip-verify` | Skip validation of TLS certificates against trusted chains | `false` |
| `-json` | Whether or not to output results as JSON. | `false` |
| `-less` | Pipe output to 'less -R' (only if stdout is terminal, and not json flag). | `true` |
2021-04-09 17:15:09 +00:00
| `-stream` | Consume results as stream. Streaming search only supports a subset of flags and parameters: trace, insecure-skip-verify, display, json. | `false` |
2020-11-19 20:01:02 +00:00
| `-trace` | Log the trace ID for requests. See https://docs.sourcegraph.com/admin/observability/tracing | `false` |
2021-11-11 08:28:46 +00:00
| `-user-agent-telemetry` | Include the operating system and architecture in the User-Agent sent with requests to Sourcegraph | `true` |
2020-11-19 20:01:02 +00:00
## Usage
```
Usage of 'src search':
2021-03-10 20:56:48 +00:00
-display int
Limit the number of results that are displayed. Only supported together with stream flag. Statistics continue to report all results. (default -1)
2020-11-19 20:01:02 +00:00
-dump-requests
Log GraphQL requests and responses to stdout
-explain-json
Explain the JSON output schema and exit.
-get-curl
Print the curl command for executing this query and exit (WARNING: includes printing your access token!)
2021-03-10 20:56:48 +00:00
-insecure-skip-verify
Skip validation of TLS certificates against trusted chains
2020-11-19 20:01:02 +00:00
-json
2021-03-10 20:56:48 +00:00
Whether or not to output results as JSON.
2020-11-19 20:01:02 +00:00
-less
2021-03-10 20:56:48 +00:00
Pipe output to 'less -R' (only if stdout is terminal, and not json flag). (default true)
-stream
2021-04-09 17:15:09 +00:00
Consume results as stream. Streaming search only supports a subset of flags and parameters: trace, insecure-skip-verify, display, json.
2020-11-19 20:01:02 +00:00
-trace
Log the trace ID for requests. See https://docs.sourcegraph.com/admin/observability/tracing
2021-11-11 08:28:46 +00:00
-user-agent-telemetry
Include the operating system and architecture in the User-Agent sent with requests to Sourcegraph (default true)
2020-11-19 20:01:02 +00:00
Examples:
Perform a search and get results:
$ src search 'repogroup:sample error'
Perform a search and get results as JSON:
$ src search -json 'repogroup:sample error'
Other tips:
Make 'type:diff' searches have colored diffs by installing https://colordiff.org
- Ubuntu/Debian: $ sudo apt-get install colordiff
- Mac OS: $ brew install colordiff
- Windows: $ npm install -g colordiff
Disable color output by setting NO_COLOR=t (see https://no-color.org).
Force color output on (not on by default when piped to other programs) by setting COLOR=t
2022-11-07 20:03:48 +00:00
Query syntax: https://docs.sourcegraph.com/code_search/reference/queries
2020-11-19 20:01:02 +00:00
2022-04-14 12:23:44 +00:00
Be careful with search strings including negation: a search with an initial
negated term may be parsed as a flag rather than as a search string. You can
use -- to ensure that src parses this correctly, eg:
$ src search -- '-repo:github.com/foo/bar error'
2020-11-19 20:01:02 +00:00
```