|
1 | 1 | # dkdc-md-cli |
2 | 2 |
|
3 | | -CLI for the [MotherDuck](https://motherduck.com) REST API. |
| 3 | +CLI for the [MotherDuck REST API](https://motherduck.com/docs/sql-reference/rest-api/motherduck-rest-api/). |
4 | 4 |
|
5 | | -## install |
| 5 | +## Install |
| 6 | + |
| 7 | +Pre-built binaries are available for Linux and macOS via Python. Windows users should install via `cargo` or use macOS/Linux. |
6 | 8 |
|
7 | 9 | ```bash |
8 | | -# from source (Rust binary) |
9 | | -cargo install --path dkdc-md-cli |
| 10 | +# Python (PyPI) — includes pre-built wheels for Linux and macOS |
| 11 | +uv tool install dkdc-md-cli |
| 12 | +uvx --from dkdc-md-cli md |
10 | 13 |
|
11 | | -# from source (Python) |
12 | | -uv tool install . |
| 14 | +# Rust (crates.io) |
| 15 | +cargo install dkdc-md-cli |
13 | 16 | ``` |
14 | 17 |
|
15 | | -## authentication |
| 18 | +## Authentication |
16 | 19 |
|
17 | | -Set one of the following environment variables: |
| 20 | +Set a MotherDuck API token via environment variable: |
18 | 21 |
|
19 | 22 | ```bash |
20 | 23 | export MOTHERDUCK_TOKEN="your-token-here" |
21 | 24 | ``` |
22 | 25 |
|
23 | | -Also accepted: `motherduck_token`, `MOTHERDUCK_API_KEY`, `motherduck_api_key`. |
| 26 | +Token resolution order (first non-empty wins): |
| 27 | + |
| 28 | +1. `--token` flag (pass `-` to read from stdin) |
| 29 | +2. `motherduck_token` |
| 30 | +3. `MOTHERDUCK_TOKEN` |
| 31 | +4. `motherduck_api_key` |
| 32 | +5. `MOTHERDUCK_API_KEY` |
| 33 | + |
| 34 | +You can also pass in `--token` to commands. |
| 35 | + |
| 36 | +## Usage |
| 37 | + |
| 38 | +``` |
| 39 | +md [--output text|json] [--token TOKEN] [--yes] <command> |
| 40 | +``` |
| 41 | + |
| 42 | +### Global flags |
24 | 43 |
|
25 | | -## usage |
| 44 | +| Flag | Short | Description | |
| 45 | +|------|-------|-------------| |
| 46 | +| `--output` | `-o` | Output format: `text` (default) or `json` | |
| 47 | +| `--token` | | API token (overrides env vars; `-` reads from stdin) | |
| 48 | +| `--yes` | `-y` | Skip confirmation prompts | |
| 49 | + |
| 50 | +### `service-account` |
26 | 51 |
|
27 | 52 | ```bash |
28 | | -# service accounts |
29 | | -md service-account create myaccount |
30 | | -md service-account delete myaccount |
| 53 | +# Create a service account |
| 54 | +md service-account create <username> |
31 | 55 |
|
32 | | -# duckling configuration |
33 | | -md duckling get myaccount |
34 | | -md duckling set myaccount --rw-size pulse --rs-size pulse --flock-size 1 |
| 56 | +# Delete a service account (prompts for confirmation) |
| 57 | +md service-account delete <username> |
| 58 | +``` |
35 | 59 |
|
36 | | -# access tokens |
37 | | -md token list myaccount |
38 | | -md token create myaccount --name my-token --ttl 3600 |
39 | | -md token delete myaccount <token-id> |
| 60 | +### `token` |
40 | 61 |
|
41 | | -# active accounts |
42 | | -md account list-active |
| 62 | +```bash |
| 63 | +# List tokens for a user |
| 64 | +md token list <username> |
| 65 | + |
| 66 | +# Create a new token |
| 67 | +md token create <username> --name <name> [--ttl <seconds>] [--token-type <type>] |
43 | 68 |
|
44 | | -# JSON output (for piping to jq, etc.) |
45 | | -md token list myaccount -o json |
| 69 | +# Delete a token (prompts for confirmation) |
| 70 | +md token delete <username> <token_id> |
46 | 71 | ``` |
47 | 72 |
|
48 | | -## development |
| 73 | +`--ttl`: time-to-live in seconds (300–31536000). Omit for no expiration. |
| 74 | + |
| 75 | +`--token-type`: `read-write` (default) or `read-scaling`. |
| 76 | + |
| 77 | +### `duckling` |
49 | 78 |
|
50 | 79 | ```bash |
51 | | -bin/setup # install rustup + uv |
52 | | -bin/build # build Rust + Python |
53 | | -bin/check # lint + test |
54 | | -bin/format # auto-format |
55 | | -bin/install # install locally |
| 80 | +# Get current duckling config |
| 81 | +md duckling get <username> |
| 82 | + |
| 83 | +# Set duckling config (at least one override required) |
| 84 | +md duckling set <username> [--rw-size <size>] [--rs-size <size>] [--flock-size <n>] |
56 | 85 | ``` |
57 | 86 |
|
58 | | -Integration tests (requires `MOTHERDUCK_TOKEN`): |
| 87 | +Instance sizes: `pulse`, `standard`, `jumbo`, `mega`, `giga`. |
| 88 | + |
| 89 | +Flock size: 0–64. `duckling set` fetches the current config and merges your overrides, so you only need to specify what you're changing. |
| 90 | + |
| 91 | +### `account` |
59 | 92 |
|
60 | 93 | ```bash |
61 | | -tests/integration-test |
| 94 | +# List active accounts and their ducklings |
| 95 | +md account list-active |
62 | 96 | ``` |
0 commit comments