1- # Sourcegraph CLI [ ![ Build Status] ( https://travis-ci.org/sourcegraph/src-cli.svg )] ( https://travis-ci.org/sourcegraph/src-cli ) [ ![ Build status ] ( https://ci.appveyor.com/api/projects/status/fwa1bkd198hyim8a?svg=true )] ( https://ci.appveyor.com/project/sourcegraph/src-cli ) [ ![ Go Report Card] ( https://goreportcard.com/badge/sourcegraph/src-cli )] ( https://goreportcard.com/report/sourcegraph/src-cli )
1+ # Sourcegraph CLI [ ![ Build Status] ( https://travis-ci.org/sourcegraph/src-cli.svg )] ( https://travis-ci.org/sourcegraph/src-cli ) [ ![ Go Report Card] ( https://goreportcard.com/badge/sourcegraph/src-cli )] ( https://goreportcard.com/report/sourcegraph/src-cli )
22
3- ** Quick links ** : [ Installation ] ( #installation ) , [ Setup ] ( #setup ) ( [ Authentication ] ( #authentication ) ), [ Usage ] ( #usage )
3+ < img src = " https://user-images.githubusercontent.com/3173176/43567326-3db5f31c-95e6-11e8-9e74-4c04079c01b0.png " style = " max-width : 350 px ; float : right ; " >
44
5- The Sourcegraph ` src ` CLI provides access to [ Sourcegraph] ( https://sourcegraph.com ) via a command-line interface.
5+ ** Quick links** :
6+ - [ Installation] ( #installation )
7+ - [ Setup] ( #setup ) ([ Authentication] ( #authentication ) )
8+ - [ Usage] ( #usage )
69
7- ![ image ] ( https://user-images.githubusercontent. com/3173176/43567326-3db5f31c-95e6-11e8-9e74-4c04079c01b0.png )
10+ The Sourcegraph ` src ` CLI provides access to [ Sourcegraph ] ( https://sourcegraph. com ) via a command-line interface.
811
912It currently provides the ability to:
1013
@@ -13,6 +16,7 @@ It currently provides the ability to:
1316 - You can provide your API access token via an environment variable or file on disk.
1417 - You can easily convert a ` src api ` command into a curl command with ` src api -get-curl ` .
1518- ** Manage repositories, users, and organizations** using the ` src repos ` , ` src users ` , and ` src orgs ` commands.
19+ - ** Execute campaign actions** as part of [ Sourcegraph campaigns] ( https://docs.sourcegraph.com/user/campaigns )
1620
1721If there is something you'd like to see Sourcegraph be able to do from the CLI, let us know! :)
1822
@@ -24,20 +28,38 @@ For Sourcegraph 3.12 and older, run the following commands verbatim (against sou
2428
2529```
2630https://github.com/sourcegraph/src-cli/releases/download/{version}/{binary}
27- ````
31+ ```
2832
29- > NOTE: If you want to use the 'src actions exec' functionality, make sure that git is installed and accessible by src.
33+ #### Requirements
34+
35+ If you want to use the ` src action exec ` functionality (see [ Sourcegraph campaigns] ( https://docs.sourcegraph.com/user/campaigns ) docs and ` src action exec -h ` ), make sure that ` git ` is installed and accessible by ` src ` .
3036
3137#### Mac OS
3238
3339``` bash
40+ # Sourcraph 3.13 and newer:
41+ curl -L https://< your-sourcegraph-instance> /.api/src-cli/src_darwin_amd64 -o /usr/local/bin/src
42+ chmod +x /usr/local/bin/src
43+
44+ # Sourcraph 3.12 and older:
3445curl -L https://sourcegraph.com/.api/src-cli/src_darwin_amd64 -o /usr/local/bin/src
3546chmod +x /usr/local/bin/src
3647```
3748
49+ or use ` brew ` to get the newest version:
50+
51+ ```
52+ brew install sourcegraph/src-cli/src-cli
53+ ```
54+
3855#### Linux
3956
4057``` bash
58+ # Sourcraph 3.13 and newer:
59+ curl -L https://< your-sourcegraph-instance> /.api/src-cli/src_linux_amd64 -o /usr/local/bin/src
60+ chmod +x /usr/local/bin/src
61+
62+ # Sourcraph 3.12 and older:
4163curl -L https://sourcegraph.com/.api/src-cli/src_linux_amd64 -o /usr/local/bin/src
4264chmod +x /usr/local/bin/src
4365```
@@ -50,14 +72,21 @@ Run in PowerShell as administrator:
5072
5173``` powershell
5274New-Item -ItemType Directory 'C:\Program Files\Sourcegraph'
75+
76+ # Sourcegraph 3.13 and newer:
77+ Invoke-WebRequest https://<your-sourcegraph-instance>/.api/src-cli/src_windows_amd64.exe -OutFile 'C:\Program Files\Sourcegraph\src.exe'
78+ # Sourcegraph 3.12 and older:
5379Invoke-WebRequest https://sourcegraph.com/.api/src-cli/src_windows_amd64.exe -OutFile 'C:\Program Files\Sourcegraph\src.exe'
80+
5481[Environment]::SetEnvironmentVariable('Path', [Environment]::GetEnvironmentVariable('Path', [EnvironmentVariableTarget]::Machine) + ';C:\Program Files\Sourcegraph', [EnvironmentVariableTarget]::Machine)
5582$env:Path += ';C:\Program Files\Sourcegraph'
5683```
5784
5885Or manually:
5986
60- - Download the latest src_windows_amd64.exe: https://sourcegraph.com/.api/src-cli/src_windows_amd64.exe and rename to ` src.exe ` .
87+ - Download the latest src_windows_amd64.exe:
88+ - Sourcegraph 3.13 and newer: https://<your-sourcegraph-instance >/.api/src-cli/src_windows_amd64.exe
89+ - Sourcegraph 3.12 and older: https://sourcegraph.com/.api/src-cli/src_windows_amd64.exe
6190- Place the file under e.g. ` C:\Program Files\Sourcegraph\src.exe `
6291- Add that directory to your system path to access it from any command prompt
6392
@@ -73,15 +102,21 @@ You can then invoke it via `sourcegraph-cli`.
73102
74103## Setup
75104
76- If you want to use ` src ` with your own Sourcegraph instance set the ` SRC_ENDPOINT ` environment variable:
105+ To use ` src ` with your own Sourcegraph instance set the ` SRC_ENDPOINT ` environment variable:
77106
78107``` sh
79108SRC_ENDPOINT=https://sourcegraph.example.com src search
80109```
81110
111+ Or via the configuration file (` ~/src-config.json ` ):
112+
113+ ``` sh
114+ {" endpoint" : " https://sourcegraph.example.com" }
115+ ```
116+
82117### Authentication
83118
84- Some Sourcegraph instances will be configured to require authentication. You can do so via the environment:
119+ Some Sourcegraph instances will be configured to require authentication. You can do so via the environment variable ` SRC_ACCESS_TOKEN ` :
85120
86121``` sh
87122SRC_ENDPOINT=https://sourcegraph.example.com SRC_ACCESS_TOKEN=" secret" src ...
@@ -90,7 +125,7 @@ SRC_ENDPOINT=https://sourcegraph.example.com SRC_ACCESS_TOKEN="secret" src ...
90125Or via the configuration file (` ~/src-config.json ` ):
91126
92127``` sh
93- {" accessToken" : " secret" , " endpoint" : " https://sourcegraph.example.com" }
128+ {" accessToken" : " secret" , " endpoint" : " https://sourcegraph.example.com" }
94129```
95130
96131See ` src -h ` for more information on specifying access tokens.
@@ -99,7 +134,22 @@ To acquire the access token, visit your Sourcegraph instance (or https://sourceg
99134
100135## Usage
101136
102- Consult ` src -h ` and ` src api -h ` for usage information.
137+ ` src ` provides different subcommands to interact with different parts of Sourcegraph:
138+
139+ - ` search ` - search for results on the configured Sourcegraph instance
140+ - ` api ` - interacts with the Sourcegraph GraphQL API
141+ - ` repos ` (alias: ` repo ` ) - manages repositories
142+ - ` users ` (alias: ` user ` ) - manages users
143+ - ` orgs ` (alias: ` org ` ) - manages organizations
144+ - ` config ` - manages global, org, and user settings
145+ - ` extsvc ` - manages external services
146+ - ` extensions ` (alias: ` ext ` ) - manages extensions
147+ - ` actions ` - runs [ campaign actions] ( https://docs.sourcegraph.com/user/campaigns/actions ) to generate patch sets
148+ - ` campaigns ` - manages [ campaigns] ( https://docs.sourcegraph.com/user/campaigns )
149+ - ` lsif ` - manages LSIF data
150+ - ` version ` - display and compare the src-cli version against the recommended version of the configured Sourcegraph instance
151+
152+ Run ` src -h ` and ` src <subcommand> -h ` for more detailed usage information.
103153
104154## Development
105155
0 commit comments