{"id":21658458,"url":"https://github.com/sourcegraph/src-cli","last_synced_at":"2025-07-17T21:31:04.992Z","repository":{"id":37601687,"uuid":"130770053","full_name":"sourcegraph/src-cli","owner":"sourcegraph","description":"Sourcegraph CLI","archived":false,"fork":false,"pushed_at":"2024-11-19T11:21:39.000Z","size":21394,"stargazers_count":277,"open_issues_count":61,"forks_count":62,"subscribers_count":63,"default_branch":"main","last_synced_at":"2024-11-19T12:43:56.405Z","etag":null,"topics":["api","cli","graphql","repo-type-cli","sourcegraph","src"],"latest_commit_sha":null,"homepage":"https://sourcegraph.com","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sourcegraph.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":"CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-04-23T23:50:32.000Z","updated_at":"2024-11-15T06:59:53.000Z","dependencies_parsed_at":"2024-05-21T15:46:40.655Z","dependency_job_id":"394c47c9-a8ef-4033-bdb6-5b2b5792957c","html_url":"https://github.com/sourcegraph/src-cli","commit_stats":{"total_commits":980,"total_committers":87,"mean_commits":"11.264367816091953","dds":0.7642857142857142,"last_synced_commit":"3ce717fe9ce315d69473191df8a033c5dc8a4a34"},"previous_names":[],"tags_count":192,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sourcegraph%2Fsrc-cli","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sourcegraph%2Fsrc-cli/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sourcegraph%2Fsrc-cli/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sourcegraph%2Fsrc-cli/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sourcegraph","download_url":"https://codeload.github.com/sourcegraph/src-cli/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":226304709,"owners_count":17603651,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["api","cli","graphql","repo-type-cli","sourcegraph","src"],"created_at":"2024-11-25T09:29:16.986Z","updated_at":"2024-11-25T09:29:28.578Z","avatar_url":"https://github.com/sourcegraph.png","language":"Go","readme":"# [Sourcegraph](https://sourcegraph.com) CLI [![Build Status](https://github.com/sourcegraph/src-cli/workflows/Go%20CI/badge.svg)](https://github.com/sourcegraph/src-cli/actions?query=workflow%3A%22Go+CI%22) [![Go Report Card](https://goreportcard.com/badge/sourcegraph/src-cli)](https://goreportcard.com/report/sourcegraph/src-cli)\n\n\u003cimg src=\"https://user-images.githubusercontent.com/3173176/43567326-3db5f31c-95e6-11e8-9e74-4c04079c01b0.png\" width=500 align=right\u003e\n\n`src` is a command line interface to Sourcegraph:\n\n- **Search \u0026 get results in your terminal**\n- **Search \u0026 get JSON** for programmatic consumption\n- Make **GraphQL API requests** with auth easily \u0026 get JSON back fast\n- Execute **[batch changes](https://docs.sourcegraph.com/batch_changes)**\n- **Manage \u0026 administrate** repositories, users, and more\n- **Easily convert src-CLI commands to equivalent curl commands**, just add --get-curl!\n\n**Note:** Using Sourcegraph 3.12 or earlier? [See the older README](https://github.com/sourcegraph/src-cli/tree/3.11.2).\n\n## Installation\n\nBinary downloads are available on the [releases tab](https://github.com/sourcegraph/src-cli/releases), and through Sourcegraph.com. _If the latest version does not work for you,_ consider using the version compatible with your Sourcegraph instance instead.\n\n### Installation: Mac OS\n\n#### Latest version\n\n```bash\ncurl -L https://sourcegraph.com/.api/src-cli/src_darwin_amd64 -o /usr/local/bin/src\nchmod +x /usr/local/bin/src\n```\n\nor with Homebrew:\n\n```bash\nbrew install sourcegraph/src-cli/src-cli\n```\n\nor with npm:\n\n```bash\nnpm install -g @sourcegraph/src\n```\n\n#### Version compatible with your Sourcegraph instance\n\nReplace `sourcegraph.example.com` with your Sourcegraph instance URL:\n\n```bash\ncurl -L https://sourcegraph.example.com/.api/src-cli/src_darwin_amd64 -o /usr/local/bin/src\nchmod +x /usr/local/bin/src\n```\n\nor, if you know the specific version to target, for example 3.43.2:\n\n```bash\nbrew install sourcegraph/src-cli/src-cli@3.43.2\n```\n\nor with npm/npx:\n\n```bash\nnpx @sourcegraph/src@3.43.2 version\n```\n\n\u003e Note: Versioned formulas are available on Homebrew for Sourcegraph versions 3.43.2 and later.\n\n### Installation: Linux\n\n#### Latest version\n\n```bash\ncurl -L https://sourcegraph.com/.api/src-cli/src_linux_amd64 -o /usr/local/bin/src\nchmod +x /usr/local/bin/src\n```\n\nor with npm:\n\n```bash\nnpm install -g @sourcegraph/src\n```\n\n#### Version compatible with your Sourcegraph instance\n\nReplace `sourcegraph.example.com` with your Sourcegraph instance URL:\n\n```bash\ncurl -L https://sourcegraph.example.com/.api/src-cli/src_linux_amd64 -o /usr/local/bin/src\nchmod +x /usr/local/bin/src\n```\n\nor, with npm/npx, if you know the specific version to target, for example 3.43.2:\n\n```bash\nnpx @sourcegraph/src@3.43.2 version\n```\n\n### Installation: Windows\n\nSee [Sourcegraph CLI for Windows](WINDOWS.md).\n\n### Installation: Docker\n\n`sourcegraph/src-cli` is published to Docker Hub. You can use the `latest` tag or a specific version such as `3.43`. To see all versions view [sourcegraph/src-cli tags](https://hub.docker.com/r/sourcegraph/src-cli/tags).\n\n```bash\ndocker run --rm=true sourcegraph/src-cli:latest search 'hello world'\n```\n\n## Log into your Sourcegraph instance\n\nRun \u003ccode\u003e\u003cstrong\u003esrc login \u003ci\u003eSOURCEGRAPH-URL\u003c/i\u003e\u003c/strong\u003e\u003c/code\u003e to authenticate `src` to access your Sourcegraph instance with your user credentials.\n\n\u003cblockquote\u003e\n\n**Examples**\n`src login https://sourcegraph.example.com`\n`src login https://sourcegraph.com`\n\n\u003c/blockquote\u003e\n\n`src` consults the following environment variables:\n\n- `SRC_ENDPOINT`: the URL to your Sourcegraph instance (such as `https://sourcegraph.example.com`)\n- `SRC_ACCESS_TOKEN`: your Sourcegraph access token (on your Sourcegraph instance, click your user menu in the top right, then select **Settings \u003e Access tokens** to create one)\n\nFor convenience, you can add these environment variables persistently. \n\n### Configuration: Mac OS / Linux\n\nAdd the following to your terminal profile file, typically accessible at `~/.bash_profile` (if using Bash) or `~/.zprofile` (if using Zsh):\n\n```\nexport SRC_ACCESS_TOKEN=my-token\nexport SRC_ENDPOINT=https://sourcegraph.example.com \n```\n\nReplace `my-token` and `https://sourcegraph.example.com` with the appropriate values for your account and instance.\n\nYou can also inline them in a single command with:\n\n```sh\nSRC_ENDPOINT=https://sourcegraph.example.com SRC_ACCESS_TOKEN=my-token src search 'foo'\n```\n\n### Configuration: Windows\n\nType the following on your PowerShell terminal:\n\n```\n$env:SRC_ENDPOINT = 'https://sourcegraph.example.com'\n$env:SRC_ACCESS_TOKEN = 'my-token'\n```\n\nReplace `my-token` and `https://sourcegraph.example.com` with the appropriate values for your account and instance.\n\nYou can also manually add them via the *System Properties* windows. Check [this post](https://www.computerhope.com/issues/ch000549.htm) for details.\n\nIs your Sourcegraph instance behind a custom auth proxy? See [auth proxy configuration](./AUTH_PROXY.md) docs.\n\n## Usage\n\n`src` provides different subcommands to interact with different parts of Sourcegraph:\n\n - `src login` - authenticate to a Sourcegraph instance with your user credentials\n - `src search` - perform searches and get results in your terminal or as JSON\n - `src api` - run Sourcegraph GraphQL API requests\n - `src batch` - execute and manage [batch changes](https://docs.sourcegraph.com/batch_changes)\n - `src repos` - manage repositories\n - `src users` - manage users\n - `src orgs` - manages organization\n - `src config` - manage global, org, and user settings\n - `src extsvc` - manage external services (repository configuration)\n - `src extensions` - manage extensions\n - `src code-intel` - manages Code Intelligence data (deprecated alias: `src lsif`)\n - `src serve-git` - serves your local git repositories over HTTP for Sourcegraph to pull\n - `src version` - check version and guaranteed-compatible version for your Sourcegraph instance\n\nRun `src -h` and `src \u003csubcommand\u003e -h` for more detailed usage information.\nYou can also read the [usage docs for the latest version of `src-cli`](https://docs.sourcegraph.com/cli/references) online.\n\n#### Optional: Renaming `src`\n\nIf you have a naming conflict with the `src` command, such as a Bash alias, you can rename the static binary. For example, on Linux / Mac OS:\n\n```sh\nmv /usr/local/bin/src /usr/local/bin/src-cli\n```\n\nYou can then invoke it via `src-cli`.\n\n## Telemetry\n\n`src` includes the operating system and architecture in the `User-Agent` header sent to Sourcegraph. For example, running `src` version 3.21.10 on an x86-64 Linux host will result in this header:\n\n```\nsrc-cli/3.21.10 linux amd64\n```\n\nTo disable this and _only_ send the version, you can set `-user-agent-telemetry=false` for a single command, or set the `SRC_DISABLE_USER_AGENT_TELEMETRY` environment variable to any non-blank string.\n\nAs with [other Sourcegraph telemetry](https://docs.sourcegraph.com/dev/background-information/telemetry), any collected data is only sent to Sourcegraph.com in aggregate form.\n\n## Development\n\nSome useful notes on developing `src` can be found in [DEVELOPMENT.md](DEVELOPMENT.md).\n","funding_links":[],"categories":["Go"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsourcegraph%2Fsrc-cli","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsourcegraph%2Fsrc-cli","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsourcegraph%2Fsrc-cli/lists"}