|
2 | 2 |
|
3 | 3 | Command line interface for [Hotdata](https://www.hotdata.dev). |
4 | 4 |
|
5 | | -## Installation |
| 5 | +## Install |
6 | 6 |
|
7 | | -Build from source (requires Rust): |
| 7 | +**Homebrew** |
| 8 | + |
| 9 | +```sh |
| 10 | +brew install hotdata-dev/tap/hotdata-cli |
| 11 | +``` |
| 12 | + |
| 13 | +**Binary (macOS, Linux)** |
| 14 | + |
| 15 | +Download a binary from [Releases](https://github.com/hotdata-dev/hotdata-cli/releases). |
| 16 | + |
| 17 | +**Build from source** (requires Rust) |
8 | 18 |
|
9 | 19 | ```sh |
10 | 20 | cargo build --release |
11 | 21 | cp target/release/hotdata /usr/local/bin/hotdata |
12 | 22 | ``` |
13 | 23 |
|
14 | | -## Getting Started |
| 24 | +## Connect |
| 25 | + |
| 26 | +Run the following command to authenticate: |
15 | 27 |
|
16 | 28 | ```sh |
17 | | -# Initialize config |
18 | | -hotdata init |
| 29 | +hotdata auth |
| 30 | +``` |
| 31 | + |
| 32 | +This launches a browser window where you can authorize the CLI to access your Hotdata account. |
19 | 33 |
|
20 | | -# Log in via browser |
21 | | -hotdata auth login |
| 34 | +Alternatively, authenticate with an API key using the `--api-key` flag: |
22 | 35 |
|
23 | | -# Check auth status |
24 | | -hotdata auth status |
| 36 | +```sh |
| 37 | +hotdata <command> --api-key <api_key> |
25 | 38 | ``` |
26 | 39 |
|
| 40 | +Or set the `HOTDATA_API_KEY` environment variable (also loaded from `.env` files): |
| 41 | + |
| 42 | +```sh |
| 43 | +export HOTDATA_API_KEY=<api_key> |
| 44 | +hotdata <command> |
| 45 | +``` |
| 46 | + |
| 47 | +API key priority (lowest to highest): config file → `HOTDATA_API_KEY` env var → `--api-key` flag. |
| 48 | + |
27 | 49 | ## Commands |
28 | 50 |
|
29 | | -### Workspaces |
| 51 | +| Command | Subcommands | Description | |
| 52 | +| :-- | :-- | :-- | |
| 53 | +| `auth` | `status`, `logout` | Authenticate (run without subcommand to log in) | |
| 54 | +| `workspaces` | `list`, `set`, `get`, `create`, `update` | Manage workspaces | |
| 55 | +| `connections` | `list`, `get`, `create`, `refresh`, `update`, `delete`, `new` | Manage connections | |
| 56 | +| `tables` | `list` | List tables and columns | |
| 57 | +| `datasets` | `list`, `create` | Manage uploaded datasets | |
| 58 | +| `query` | | Execute a SQL query | |
| 59 | +| `results` | `list` | Retrieve stored query results | |
| 60 | +| `skills` | `install`, `status` | Manage the hotdata-cli agent skill | |
| 61 | + |
| 62 | +## Global options |
| 63 | + |
| 64 | +| Option | Description | Type | Default | |
| 65 | +| :-- | :-- | :-- | :-- | |
| 66 | +| `--api-key` | API key (overrides env var and config) | string | | |
| 67 | +| `-v, --version` | Print version | boolean | | |
| 68 | +| `-h, --help` | Print help | boolean | | |
| 69 | + |
| 70 | +## Workspaces |
30 | 71 |
|
31 | 72 | ```sh |
32 | | -hotdata workspace list [--format table|json|yaml] |
| 73 | +hotdata workspaces list [--format table|json|yaml] |
| 74 | +hotdata workspaces set [<workspace_id>] |
33 | 75 | ``` |
34 | 76 |
|
35 | | -### Connections |
| 77 | +- `list` shows all workspaces with a `*` marker on the active one. |
| 78 | +- `set` switches the active workspace. Omit the ID for interactive selection. |
| 79 | +- The active workspace is used as the default for all commands that accept `--workspace-id`. |
| 80 | + |
| 81 | +## Connections |
36 | 82 |
|
37 | 83 | ```sh |
38 | | -hotdata connections list <workspace_id> [--format table|json|yaml] |
| 84 | +hotdata connections list [--workspace-id <id>] [--format table|json|yaml] |
| 85 | +hotdata connections get <connection_id> [--workspace-id <id>] [--format yaml|json|table] |
| 86 | +hotdata connections refresh <connection_id> [--workspace-id <id>] |
| 87 | +hotdata connections new [--workspace-id <id>] |
39 | 88 | ``` |
40 | 89 |
|
41 | | -### Tables |
| 90 | +- `list` returns `id`, `name`, `source_type` for each connection. |
| 91 | +- `refresh` triggers a schema refresh for a connection. |
| 92 | +- `new` launches an interactive connection creation wizard. |
| 93 | + |
| 94 | +### Create a connection |
42 | 95 |
|
43 | 96 | ```sh |
44 | | -# List all tables in a workspace |
45 | | -hotdata tables list <workspace_id> [--format table|json|yaml] |
| 97 | +# List available connection types |
| 98 | +hotdata connections create list [--format table|json|yaml] |
| 99 | + |
| 100 | +# Inspect schema for a connection type |
| 101 | +hotdata connections create list <type_name> --format json |
46 | 102 |
|
47 | | -# List columns for a specific connection |
48 | | -hotdata tables list <workspace_id> --connection-id <connection_id> [--format table|json|yaml] |
| 103 | +# Create a connection |
| 104 | +hotdata connections create --name "my-conn" --type postgres --config '{"host":"...","port":5432,...}' |
49 | 105 | ``` |
50 | 106 |
|
51 | | -### Query |
| 107 | +## Tables |
52 | 108 |
|
53 | 109 | ```sh |
54 | | -hotdata query "<sql>" --workspace-id <workspace_id> [--connection <connection_id>] [--format table|json|csv] |
| 110 | +hotdata tables list [--workspace-id <id>] [--connection-id <id>] [--schema <pattern>] [--table <pattern>] [--limit <n>] [--cursor <token>] [--format table|json|yaml] |
55 | 111 | ``` |
56 | 112 |
|
57 | | -## Releasing |
58 | | - |
59 | | -Releases use a two-phase workflow wrapping [`cargo-release`](https://github.com/crate-ci/cargo-release). |
| 113 | +- Without `--connection-id`: lists all tables with `table`, `synced`, `last_sync`. |
| 114 | +- With `--connection-id`: includes column details (`column`, `data_type`, `nullable`). |
| 115 | +- `--schema` and `--table` support SQL `%` wildcard patterns. |
| 116 | +- Tables are displayed as `<connection>.<schema>.<table>` — use this format in SQL queries. |
60 | 117 |
|
61 | | -**Phase 1 — prepare** |
| 118 | +## Datasets |
62 | 119 |
|
63 | 120 | ```sh |
64 | | -scripts/release.sh prepare <version> |
65 | | -# e.g. scripts/release.sh prepare 0.2.0 |
| 121 | +hotdata datasets list [--workspace-id <id>] [--limit <n>] [--offset <n>] [--format table|json|yaml] |
| 122 | +hotdata datasets <dataset_id> [--workspace-id <id>] [--format table|json|yaml] |
| 123 | +hotdata datasets create --file data.csv [--label "My Dataset"] [--table-name my_dataset] |
| 124 | +hotdata datasets create --sql "SELECT ..." --label "My Dataset" |
66 | 125 | ``` |
67 | 126 |
|
68 | | -This will: |
69 | | -1. Create a `release/<version>` branch |
70 | | -2. Bump the version in `Cargo.toml`, update `CHANGELOG.md`, and push the branch |
71 | | -3. Open a GitHub pull request and launch it in the browser |
| 127 | +- Datasets are queryable as `datasets.main.<table_name>`. |
| 128 | +- `--file`, `--sql`, and `--query-id` are mutually exclusive. |
| 129 | +- Format is auto-detected from file extension or content. |
| 130 | +- Piped stdin is supported: `cat data.csv | hotdata datasets create --label "My Dataset"` |
72 | 131 |
|
73 | | -Squash and merge the PR into `main` when ready. |
| 132 | +## Query |
74 | 133 |
|
75 | | -**Phase 2 — finish** |
| 134 | +```sh |
| 135 | +hotdata query "<sql>" [--workspace-id <id>] [--connection <connection_id>] [--format table|json|csv] |
| 136 | +``` |
| 137 | + |
| 138 | +- Default format is `table`, which prints results with row count and execution time. |
| 139 | +- Use `--connection` to scope the query to a specific connection. |
| 140 | + |
| 141 | +## Results |
76 | 142 |
|
77 | 143 | ```sh |
78 | | -scripts/release.sh finish |
| 144 | +hotdata results <result_id> [--workspace-id <id>] [--format table|json|csv] |
| 145 | +hotdata results list [--workspace-id <id>] [--limit <n>] [--offset <n>] [--format table|json|yaml] |
79 | 146 | ``` |
80 | 147 |
|
81 | | -Run this from any branch after the PR is merged. It will switch to `main`, pull the latest, tag the release, and trigger the dist workflow. |
| 148 | +- Query results include a `result-id` in the table footer — use it to retrieve past results without re-running queries. |
82 | 149 |
|
83 | 150 | ## Configuration |
84 | 151 |
|
85 | 152 | Config is stored at `~/.hotdata/config.yml` keyed by profile (default: `default`). |
86 | 153 |
|
87 | | -Environment variable overrides: |
| 154 | +| Variable | Description | Default | |
| 155 | +| :-- | :-- | :-- | |
| 156 | +| `HOTDATA_API_KEY` | API key (overrides config file) | | |
| 157 | +| `HOTDATA_API_URL` | API base URL | `https://api.hotdata.dev/v1` | |
| 158 | +| `HOTDATA_APP_URL` | App URL for browser login | `https://app.hotdata.dev` | |
| 159 | + |
| 160 | +## Releasing |
| 161 | + |
| 162 | +Releases use a two-phase workflow wrapping [`cargo-release`](https://github.com/crate-ci/cargo-release). |
| 163 | + |
| 164 | +**Phase 1 — prepare** |
| 165 | + |
| 166 | +```sh |
| 167 | +scripts/release.sh prepare <version> |
| 168 | +``` |
| 169 | + |
| 170 | +Creates a `release/<version>` branch, bumps the version, updates `CHANGELOG.md`, pushes the branch, and opens a pull request. |
| 171 | + |
| 172 | +**Phase 2 — finish** |
| 173 | + |
| 174 | +```sh |
| 175 | +scripts/release.sh finish |
| 176 | +``` |
88 | 177 |
|
89 | | -| Variable | Description | |
90 | | -|--------------------|------------------------------------------| |
91 | | -| `HOTDATA_API_KEY` | API key (overrides config) | |
92 | | -| `HOTDATA_API_URL` | API base URL (default: `https://api.hotdata.dev/v1`) | |
93 | | -| `HOTDATA_APP_URL` | App URL for browser login (default: `https://app.hotdata.dev`) | |
| 178 | +Switches to `main`, pulls latest, tags the release, and triggers the dist workflow. |
0 commit comments