Giter Club home page Giter Club logo

src-cli's Introduction

Sourcegraph CLI Build Status Build status Go Report Card

The Sourcegraph src CLI provides access to Sourcegraph via a command-line interface.

image

It currently provides the ability to:

  • Execute search queries from the command line and get nice colorized output back (or JSON, optionally).
  • Execute GraphQL queries against a Sourcegraph instance, and get JSON results back (src api).
    • You can provide your API access token via an environment variable or file on disk.
    • You can easily convert a src api command into a curl command with src api -get-curl.
  • Manage repositories, users, and organizations using the src repos, src users, and src orgs commands.

If there is something you'd like to see Sourcegraph be able to do from the CLI, let us know! :)

Installation

Mac OS:

curl -L https://github.com/sourcegraph/src-cli/releases/download/latest/src_darwin_amd64 -o /usr/local/bin/src
chmod +x /usr/local/bin/src

Linux:

curl -L https://github.com/sourcegraph/src-cli/releases/download/latest/src_linux_amd64 -o /usr/local/bin/src
chmod +x /usr/local/bin/src

Windows:

Note: Windows support is still rough around the edges, but is available. If you encounter issues, please let us know by filing an issue :)

Run in PowerShell as administrator:

New-Item -ItemType Directory 'C:\Program Files\Sourcegraph'
Invoke-WebRequest https://github.com/sourcegraph/src-cli/releases/download/latest/src_windows_amd64.exe -OutFile 'C:\Program Files\Sourcegraph\src.exe'
[Environment]::SetEnvironmentVariable('Path', [Environment]::GetEnvironmentVariable('Path', [EnvironmentVariableTarget]::Machine) + ';C:\Program Files\Sourcegraph', [EnvironmentVariableTarget]::Machine)
$env:Path += ';C:\Program Files\Sourcegraph'

Or manually:

  • Download the latest src_windows_amd64.exe and rename to src.exe.
  • Place the file under e.g. C:\Program Files\Sourcegraph\src.exe
  • Add that directory to your system path to access it from any command prompt

Usage

Consult src -h and src api -h for usage information.

Authentication

Some Sourcegraph instances will be configured to require authentication. You can do so via the environment:

SRC_ACCESS_TOKEN="secret" src ...

Or via the configuration file (~/src-config.json):

	{"accessToken": "secret"}

See src -h for more information on specifying access tokens.

To acquire the access token, visit your Sourcegraph instance (or https://sourcegraph.com), click your profile picture, and select access tokens in the left hand menu.

Development

If you want to develop the CLI, you can install it with go get:

go get -u github.com/sourcegraph/src-cli/cmd/src

Releasing

  1. Find the latest version (either via the releases tab on GitHub or via git tags) to determine which version you are releasing.
  2. VERSION=9.9.9 ./release.sh (replace 9.9.9 with the version you are releasing)
  3. Travis will automatically perform the release. Once it has finished, confirm that the curl commands fetch the latest version above.

src-cli's People

Contributors

attfarhan avatar chrismwendt avatar felixfbecker avatar ggilmore avatar kevinzliu avatar mdaniel avatar slimsag avatar sqs avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.