From aef66bac97250316546ec5269f135e8029facab8 Mon Sep 17 00:00:00 2001 From: Sathish Kumar H S <123226888+SathishKumarHS@users.noreply.github.com> Date: Mon, 27 Mar 2023 20:09:42 +0530 Subject: [PATCH] Initial commit --- LICENSE | 6 +++ README.md | 111 +++++++++++++++++++++++++++++++++++++++++ install_completions.sh | 58 +++++++++++++++++++++ 3 files changed, 175 insertions(+) create mode 100644 LICENSE create mode 100644 README.md create mode 100644 install_completions.sh diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..4d192f1 --- /dev/null +++ b/LICENSE @@ -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. + */ \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..56da591 --- /dev/null +++ b/README.md @@ -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 --usr +``` + +**Arguments:** + +`` : The unique slug name of your DevOrg to which you want to login. + +`` : 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) diff --git a/install_completions.sh b/install_completions.sh new file mode 100644 index 0000000..1b86c86 --- /dev/null +++ b/install_completions.sh @@ -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"