Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
SathishKumarHS authored and petermari committed Jul 14, 2023
0 parents commit aef66ba
Show file tree
Hide file tree
Showing 3 changed files with 175 additions and 0 deletions.
6 changes: 6 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/**
* Copyright (C) DevRev - All Rights Reserved
*
* The source and binary code in this repository are protected under international
* copyright law. All rights reserved and protected by the copyright holders.
*/
111 changes: 111 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
# DevRev CLI

This repo provides the latest CLI release from DevRev. It is a tool that simplifies working
with the DevRev REST API.

## Install with Debian Package

Supported architectures:

- linux amd64
- linux arm64

Download the debian package from [https://github.com/devrev/cli/releases/latest](https://github.com/devrev/cli/releases/latest)
and install it using the following command:

```bash
sudo dpkg -i devrev_0.4.0-linux_amd64.deb
```

or

```bash
sudo dpkg -i devrev_0.4.0-linux_arm64.deb
```

also run the below command to **install the completions**:

```bash
wget https://raw.githubusercontent.com/devrev/cli/main/install_completions.sh && sh install_completions.sh /usr/local/bin/devrev
```

Note: **/usr/local/bin/devrev** path may vary based on your debian installation

### Uninstall debian package

Use this command to deinstall the devrev debian package:

```bash
sudo dpkg -r devrev
```

## Installation with Homebrew

Homebrew installation supports the following architectures:

- darwin amd64
- darwin arm64
- linux arm64
- linux amd64

Download the brew formula [devrev.rb](https://github.com/devrev/cli/releases/latest/download/devrev.rb) or run the below command:

```bash
wget https://github.com/devrev/cli/releases/latest/download/devrev.rb
```

Install the downloaded Homebrew formula file devrev.rb using below command:

```bash
brew install ./devrev.rb
```

also run the below command to **install the completions**:

```bash
wget https://raw.githubusercontent.com/devrev/cli/main/install_completions.sh && sh install_completions.sh /opt/homebrew/bin/devrev
```

Note: **/opt/homebrew/bin/devrev** path may vary based on your homebrew installation

### Uninstall devrev CLI

```bash
brew uninstall devrev
```

## Usage

The DevRev CLI provides several subcommands that can be used to perform various tasks. Here are some examples:

### CLI version

```bash
devrev --version
```

### Authentication to DevRev API

```bash
devrev profiles authenticate --org <DevOrg-slug-name> --usr <[email protected]>
```

**Arguments:**

`<DevOrg-slug-name>` : The unique slug name of your DevOrg to which you want to login.

`<[email protected]>` : Your registered user email for profile.

### CLI help

```bash
devrev --help
```

### License

DevRev CLI is proprietary software and is not open source. You may use it for your commercial use, but you may not distribute or modify it without our permission.

## Support

If you have any issues or questions about DevRev CLI, please contact our support team at [https://devrev.ai](https://devrev.ai)
58 changes: 58 additions & 0 deletions install_completions.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
#!/bin/sh
# A script for installing shell completions

set -e

shell_name="$(basename "$SHELL")"
devrev_bin="$1"

if [ ! -f "$devrev_bin" ]; then
echo "devrev executable not found, please pass the path as the first argument"
exit 1
fi

install_bash_completions() {
completions_dir="${BASH_COMPLETION_USER_DIR:-${XDG_DATA_HOME:-$HOME/.local/share}/bash-completion}"/completions
[ ! -d "$completions_dir" ] && mkdir -p "$completions_dir"
"$devrev_bin" completion bash > "$completions_dir"/devrev
}

install_zsh_completions() {
if [ -d "$HOME"/.oh-my-zsh ]; then
# If the user is using o-my-zsh, this is a natural place to put the completions
completions_dir=$HOME/.oh-my-zsh/completions
[ ! -d "$completions_dir" ] && mkdir -p "$completions_dir"
"$devrev_bin" completion zsh > "$completions_dir"/_devrev
else
# Otherwise put it in our own directory, and add it to the fpath
completions_dir=$HOME/.devrev/completions
[ ! -d "$completions_dir" ] && mkdir -p "$completions_dir"
"$devrev_bin" completion zsh > "$completions_dir"/_devrev

echo -e "fpath+=(""$completions_dir"")\n$(cat "$HOME"/.zshrc)" > "$HOME"/.zshrc
printf "Completion script was installed in '%s'. We made an effort to add " \
"this to the fpath in .zshrc, but you need to ensure that compinit is " \
"run after it in the .zshrc" "$completions_dir"
fi
}

install_fish_completions() {
completions_dir=$HOME/.config/fish/completions
[ ! -d "$completions_dir" ] && mkdir -p "$completions_dir"
"$devrev_bin" completion fish > "$completions_dir"/devrev.fish
}

if [ "$shell_name" = "zsh" ]; then
install_zsh_completions
elif [ "$shell_name" = "bash" ]; then
install_bash_completions
elif [ "$shell_name" = "fish" ]; then
install_fish_completions
else
printf "Shell '%s' has not been added to the script yet, generate " \
"completions with 'devrev completion [shell_name]' and save the output to " \
"wherever your shell reads them from, then create a new PR with your shell " \
"added to the script" "$shell_name"
fi

echo "Installed completions for $shell_name shell"

0 comments on commit aef66ba

Please sign in to comment.