Skip to main content

CLI

Background​

DoiT provides a command-line interface (CLI) for interacting with the DoiT API directly from your terminal. The dci CLI is a standalone binary that dynamically generates commands from the DoiT API, handles authentication, and supports multiple output formats.

This documentation covers:

  • Installing the CLI on macOS, Windows, and Linux
  • Shell completion setup
  • Authentication via OAuth or API key
  • Command discovery and usage patterns
  • Output formats and scripting
  • A full, generated command reference (available via the sidebar)

Download and install​

Install the dci binary using one of the methods below.

macOS (Homebrew)​

brew install doitintl/dci-cli/dci

Windows (WinGet)​

winget install DoiT.dci

Windows (Scoop)​

scoop bucket add doitintl https://github.com/doitintl/dci-cli
scoop install dci

Linux (Debian/Ubuntu)​

Download the .deb package from the latest release, then install:

sudo dpkg -i dci_*_linux_amd64.deb

Linux (RHEL/Fedora)​

Download the .rpm package from the latest release, then install:

sudo rpm -i dci_*_linux_amd64.rpm

Direct download​

Prebuilt binaries for all platforms are available on the GitHub Releases page.

Validate the installation​

dci --version

Shell completion​

The dci CLI can generate shell completion scripts for tab-completing commands, subcommands, and flags.

Bash​

# System-wide (requires sudo):
dci completion bash > /etc/bash_completion.d/dci

# Per-user:
mkdir -p ~/.bash_completions
dci completion bash > ~/.bash_completions/dci
echo 'source ~/.bash_completions/dci' >> ~/.bashrc

Zsh​

dci completion zsh > "${fpath[1]}/_dci"

Then restart your shell or run exec zsh to pick up the new completions.

Fish​

dci completion fish > ~/.config/fish/completions/dci.fish

PowerShell​

dci completion powershell > dci.ps1
# Then add `. /path/to/dci.ps1` to your PowerShell profile.

Completion covers all API commands (list-budgets, list-reports, query, etc.) with descriptions, and includes flag completion for each command. API command completion requires an active auth session (dci login or DCI_API_KEY).


Authentication​

The CLI supports two authentication methods.

Interactive (OAuth)​

Run dci login to authenticate via the DoiT Console in your browser:

dci login

This opens a browser window, prompts you to log in, completes an OAuth flow, and caches credentials locally. The first time you run any command, the CLI triggers this flow automatically.

To clear cached credentials:

dci logout

API key (CI/automation)​

For non-interactive environments such as CI/CD pipelines, set the DCI_API_KEY environment variable:

export DCI_API_KEY=<your-api-key>

When DCI_API_KEY is set, the CLI uses it instead of OAuth.

Verify authentication​

Check your current auth method and customer context:

dci status

Getting started​

After installing and authenticating, try a few commands:

dci list-budgets
dci list-reports
dci query body.query:"SELECT * FROM aws_cur_2_0 LIMIT 10"

Use --help on any command for inline usage details:

dci --help
dci list-budgets --help

Command structure​

Commands are generated directly from the DoiT API. The general structure is:

dci <command> [arguments] [flags]

Examples:

dci list-alerts
dci get-alert <id>
dci list-budgets
dci list-reports

For commands that accept a request body, pass a JSON file with --body:

dci create-alert --body @alert.json

Output formats​

Commands support multiple output formats via the --output flag:

FormatDescription
tableHuman-readable tabular display (default)
jsonMachine-readable JSON β€” recommended for scripting
yamlYAML structured output
autoAlias for table
dci list-budgets --output json
dci list-budgets --output table
dci list-budgets --output yaml

Table output options​

When using table output (the default), the following flags control how the table is rendered:

FlagShortDefaultDescription
--table-mode-Mfitfit truncates long cell values to fit the terminal width. wrap wraps them across multiple lines.
--table-columns-Call columnsComma-separated list of columns to include, in the order listed.
--table-width-Wauto-detectTable width in columns. Defaults to terminal width, falls back to the COLUMNS env var, then 120.
--table-max-col-width-X0 (auto)Maximum width per column when fitting or wrapping. 0 lets the CLI decide automatically.

Example combining multiple options:

dci list-budgets --table-mode wrap --table-columns id,name,amount --table-max-col-width 40

Environment variables​

VariableDescription
DCI_API_KEYAPI key for non-interactive authentication
DCI_CUSTOMER_CONTEXTOverride the customer context for commands

Configuration​

Configuration is stored in the OS-specific config directory and is created automatically on first run.

OSPath
macOS~/Library/Application Support/dci/apis.json
Linux~/.config/dci/apis.json
Windows%APPDATA%\dci\apis.json

To reset configuration, delete the file at the path above and re-run dci login.


Using the CLI in scripts​

The CLI is suitable for shell scripts and automation.

Recommendations:

  • Use --output json for machine-readable output
  • Set DCI_API_KEY for non-interactive authentication
  • Avoid interactive commands in non-TTY environments

Example:

export DCI_API_KEY=<your-api-key>
budgets=$(dci list-budgets --output json)

Troubleshooting​

Authentication issues​

If authentication expires or fails, re-authenticate:

dci login

Verbose output​

Enable verbose logging to debug requests:

dci list-budgets --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 using DCI_API_KEY