Skip to main content

CLI

Background

DoiT provides a command-line interface (CLI) for interacting with the DoiT API directly from your terminal. The CLI is built on top of Restish, an OpenAPI-driven CLI that dynamically generates commands, handles authentication, and supports multiple output formats.

This documentation covers:

  • Installing the CLI on macOS, Windows, and Linux
  • Initial authentication and configuration
  • Shell auto-completion
  • Command discovery and usage patterns
  • A full, generated command reference (available via the sidebar)

Download and install

The DoiT CLI uses the restish binary. Install it using one of the methods below.

brew install restish

Linux / macOS (Nix – optional)

If you already use Nix or NixOS:

nix-env -iA nixpkgs.restish

All platforms (Go)

If you have Go installed (Go 1.18+):

go install github.com/danielgtaylor/restish@latest

Make sure that $GOPATH/bin (or $HOME/go/bin) is included in your PATH.

Validate the installation

restish --version

Configure authentication

After installing, configure the DoiT API endpoint:

restish api configure dci https://api.doit.com

This command will:

  1. Open the DoiT Console in your browser
  2. Prompt you to log in
  3. Complete an OAuth flow
  4. Store the access token locally

Once completed, authentication is configured and the CLI is ready to use.


Shell auto-completion

The CLI supports shell auto-completion for commands, subcommands, and flags.

Bash

Add the following to ~/.bashrc or ~/.bash_profile:

eval "$(restish completion bash)"

Zsh

Add the following to ~/.zshrc:

eval "$(restish completion zsh)"

Fish

restish completion fish | source

Command structure

Commands are generated directly from the DoiT API.

General structure:

restish dci <resource> <action> [arguments] [flags]

Examples:

restish dci list-alerts
restish dci get-alert <id>
restish dci create-alert --body @alert.json

Finding commands and help

List all available commands:

restish dci --help

Get help for a specific command:

restish dci list-alerts --help

Profiles and environments

Restish supports multiple profiles, allowing you to work with different environments or accounts.

List configured profiles:

restish api list

Configure an additional profile:

restish api configure <profile-name> https://api.doit.com

Use a specific profile:

restish --profile <profile-name> dci list-alerts

Output formats

Commands support multiple output formats.

Examples:

restish dci list-alerts --output json
restish dci list-alerts --output table

JSON output is recommended for scripting and automation.


Using the CLI in scripts

The CLI is suitable for shell scripts and automation.

Recommendations:

  • Use --output json for machine-readable output
  • Avoid interactive commands in non-TTY environments
  • Use explicit profiles in CI/CD pipelines

Example:

alerts=$(restish dci list-alerts --output json)

Troubleshooting

Authentication issues

If authentication expires or fails, re-run:

restish api configure dci https://api.doit.com

Verbose output

Enable verbose logging to debug requests:

restish dci list-alerts --rsh-verbose

Next steps

  • Browse the CLI command reference in the sidebar
  • Use --help on any command for inline usage details
  • Integrate the CLI into scripts and automation