Skip to main content
Documentation

Command Line Interface

The Diafunc CLI is a command-line wrapper over the public APIs, intended for scripting, automation, and everyday terminal work against the platform. Usable against any Diafunc endpoint, from production to a local development instance.

Installation

The recommended way to install is the shell installer. It drops a single self-contained binary on your machine, no Node.js needed. The default install location is ~/.local/bin/diafunc on Linux/macOS or %LOCALAPPDATA%\diafunc\bin\diafunc.exe on Windows.

Shell installer (Linux, macOS)
curl -fsSL https://diafunc.com/cli/install.sh | sh

PowerShell installer (Windows)
irm https://diafunc.com/cli/install.ps1 | iex

Override the install location with DIAFUNC_CLI_INSTALL_DIR. The shell installer always serves the latest release; install older versions via npm (npm install -g @diafunc/cli@<version>).

If you already have Node.js 20 or newer, the npm package works equally well:

npm
npm install -g @diafunc/cli

For environments where neither shell installer can run, download the matching binary from https://diafunc.com/cli/, verify its SHA-256 against https://diafunc.com/cli/SHA256SUMS, and place it on your PATH.

Updating and removing

diafunc update upgrades the CLI in place: for shell-installed binaries it re-runs the installer at the same path; for npm-installed CLIs it prints the corresponding npm install -g command. diafunc uninstall is the symmetric removal command, with optional prompts to wipe ~/.diafunc/ (config and credentials).

Update or uninstall
diafunc update      # upgrade to the latest release in place
diafunc uninstall   # remove the binary (with an optional prompt to wipe ~/.diafunc/)

Every TTY invocation prints a low-key one-line notice when a newer release is available. The check is cached for 24 hours and skipped entirely outside an interactive terminal; suppress with DIAFUNC_NO_UPDATE_CHECK=1.

Authentication

diafunc auth login supports two modes. The default is an OIDC device-code flow: the CLI prints a short code and a URL, you approve the login in your browser, and the CLI caches the resulting tokens locally. For scripts and CI there is a non-interactive path that accepts a dfat_-prefixed API token. See the Authentication page for how to issue one.

Log in
# OIDC device-code flow (default): approve in the browser
diafunc auth login

# Non-interactive, for scripts and CI
diafunc auth login --token dfat_your_token_here

Credentials are stored at ~/.diafunc/config.json with 0600 permissions. diafunc auth logout clears them locally and, for device-code sessions, revokes the refresh token at the identity provider.

Defaults

Set defaults for project, branch, and output format so individual commands stay short.

Set defaults
diafunc config set defaults.project my-project
diafunc config set defaults.branch main
diafunc config set defaults.output json

Profiles

Profiles let you switch between multiple environments (for example, production and a local development instance) without re-authenticating each time.

Manage profiles
diafunc config profile add staging --endpoint https://staging.diafunc.com
diafunc config profile use staging
diafunc config profile list

Entity references

Most commands accept a compact reference instead of four separate arguments. The reference falls back to your configured defaults for any parts you leave out.

Entity reference forms
# Just entity ID (uses default project + branch)
diafunc entity get my-table

# Entity with branch override
diafunc entity get my-table:feature-1

# Explicit project, default branches
diafunc entity get my-project//my-table

# Fully explicit
diafunc entity get my-project/main/my-table/main

Output formats

Every command supports three output formats through the -o flag: a human-readable default, JSON for piping into tools like jq, and TSV for pipelines built on awk or cut.

Choose output format
diafunc project list              # Human-readable (default)
diafunc project list -o json      # JSON (for piping to jq)
diafunc project list -o table     # TSV (for awk/cut)

Dry run

Preview any mutating command with --dry-run to see what it would do without actually changing anything.

Preview a mutation
diafunc project create --visibility PRIVATE --dry-run

Shell completions

The CLI ships completions for bash, zsh, and fish.

Install completions
# Bash: add to ~/.bashrc
eval "$(diafunc completion bash)"

# Zsh: add to ~/.zshrc
eval "$(diafunc completion zsh)"

# Fish
diafunc completion fish | source

What next?