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:
| Format | Description |
|---|---|
table | Human-readable tabular display (default) |
json | Machine-readable JSON β recommended for scripting |
yaml | YAML structured output |
auto | Alias 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:
| Flag | Short | Default | Description |
|---|---|---|---|
--table-mode | -M | fit | fit truncates long cell values to fit the terminal width. wrap wraps them across multiple lines. |
--table-columns | -C | all columns | Comma-separated list of columns to include, in the order listed. |
--table-width | -W | auto-detect | Table width in columns. Defaults to terminal width, falls back to the COLUMNS env var, then 120. |
--table-max-col-width | -X | 0 (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β
| Variable | Description |
|---|---|
DCI_API_KEY | API key for non-interactive authentication |
DCI_CUSTOMER_CONTEXT | Override the customer context for commands |
Configurationβ
Configuration is stored in the OS-specific config directory and is created automatically on first run.
| OS | Path |
|---|---|
| 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 jsonfor machine-readable output - Set
DCI_API_KEYfor 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
--helpon any command for inline usage details - Integrate the CLI into scripts and automation using
DCI_API_KEY