Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
[![Follow on X](https://img.shields.io/badge/X-Follow_ClickHouseDB-000000)](https://x.com/ClickHouseDB)
[![YouTube videos](https://img.shields.io/badge/YouTube-Watch_ClickHouseDB-FF0000)](https://www.youtube.com/@ClickHouseDB)

`clickhousectl` (`chctl`) is the official CLI for ClickHouse, from local development to ClickHouse Cloud.
`clickhousectl` (`chctl`) is the official CLI for ClickHouse and Postgres, from local development to ClickHouse Cloud.


## What can the CLI do?
Expand Down
2 changes: 1 addition & 1 deletion crates/clickhousectl/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name = "clickhousectl"
version = "0.6.0"
edition.workspace = true
rust-version.workspace = true
description = "The CLI for ClickHouse: local and cloud."
description = "The CLI for ClickHouse and Postgres: local and cloud."
license.workspace = true
repository.workspace = true
homepage.workspace = true
Expand Down
11 changes: 6 additions & 5 deletions crates/clickhousectl/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@ macro_rules! root_agent_context {
() => {
"\
CONTEXT FOR AGENTS:
Postgres for an app's transactional data: `local postgres start` (needs Docker), `cloud postgres create`
Cloud auth: OAuth (`cloud auth login`) is read-only; API keys
(`cloud auth login --api-key X --api-secret Y`) allow writes.
Create account: `cloud auth signup`
Typical cloud flow: `cloud auth signup` -> `cloud auth login --api-key X --api-secret Y` -> `cloud service create`
Check state first: `clickhousectl cloud auth status --json`, `clickhousectl local status --json`
Find a command or flag by keyword: `clickhousectl search <words>`
Install the ClickHouse agent skills: `clickhousectl skills --agent claude`"
Install the ClickHouse and Postgres agent skills: `clickhousectl skills --agent claude`"
};
}

Expand All @@ -40,7 +40,7 @@ const ROOT_AFTER_HELP: &str = root_agent_context!();

#[derive(Args)]
#[command(name = "clickhousectl")]
#[command(about = "The official CLI for ClickHouse: local and cloud", long_about = None)]
#[command(about = "The official CLI for ClickHouse and Postgres: local and cloud", long_about = None)]
#[command(version, disable_version_flag = true)]
#[command(arg(clap::Arg::new("version")
.short('V')
Expand Down Expand Up @@ -79,7 +79,8 @@ CONTEXT FOR AGENTS:
Outside a project they use the current directory, and server starts create `.clickhouse/` there.
CLICKHOUSECTL_PROJECT_DIR=<dir> skips discovery: <dir> is the project root (`local init` too).
`clickhousectl local clickhouse start` bootstraps from zero — installs `latest` if nothing is set up.
Typical flow: `local init` -> `local clickhouse start` -> `local client -q 'SELECT 1'`")]
Typical flow: `local init` -> `local clickhouse start` -> `local client -q 'SELECT 1'`
Postgres flow (needs Docker): `local init` -> `local postgres start` -> `local postgres client -q 'SELECT 1'`")]
Local(LocalArgs),

/// Manage ClickHouse and Postgres in ClickHouse Cloud
Expand All @@ -92,7 +93,7 @@ CONTEXT FOR AGENTS:
`cloud auth status` shows the active source; --org-id auto-detects only with exactly one org.
delete/remove act immediately — there is no confirmation prompt.
Exit codes: 0 success, 1 error, 2 usage error, 3 cancelled, 4 auth required.
Typical flow: `cloud auth login --api-key X --api-secret Y` -> `cloud service list`")]
Typical flow: `cloud auth login --api-key X --api-secret Y` -> `cloud service list` or `cloud postgres list`")]
Cloud(Box<CloudArgs>),

/// Install ClickHouse agent skills into supported coding agents
Expand Down
2 changes: 1 addition & 1 deletion crates/clickhousectl/src/local/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ CONTEXT FOR AGENTS:
Idempotent — re-running only creates what is missing.
Initializes the current directory: inside another project it creates a nested one, which then
wins for this directory and below. With CLICKHOUSECTL_PROJECT_DIR set, initializes that instead.
Next: `clickhousectl local clickhouse start`")]
Next: `clickhousectl local clickhouse start`, `clickhousectl local postgres start` (needs Docker)")]
Init,

/// Manage local ClickHouse servers
Expand Down
19 changes: 19 additions & 0 deletions crates/clickhousectl/src/search.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@ const SYNONYMS: &[(&[&str], &str)] = &[
(&["access", "list"], "allow"),
(&["allowlist"], "allow"),
(&["whitelist"], "allow"),
// What Postgres is for, and its long name; the commands only say `postgres`.
(&["oltp"], "postgres"),
(&["transactional"], "postgres"),
(&["relational"], "postgres"),
(&["postgresql"], "postgres"),
];

/// The query's distinct words, with synonym phrases replaced.
Expand Down Expand Up @@ -495,6 +500,20 @@ mod tests {
}
}

#[test]
fn postgres_purpose_words_reach_the_postgres_commands() {
for words in ["oltp", "transactional database", "relational", "PostgreSQL"] {
let output = search(&real_index(), &query(words), 5);
let found = commands(&output);
assert!(
found
.iter()
.any(|command| command.split(' ').nth(1) == Some("postgres")),
"{words}: {found:?}"
);
}
}

#[test]
fn synonym_phrases_are_found_and_targets_are_indexed_words() {
let words: BTreeSet<String> = real_index()
Expand Down
2 changes: 1 addition & 1 deletion npm/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "clickhousectl",
"version": "0.6.0",
"description": "The CLI for ClickHouse: local and cloud.",
"description": "The CLI for ClickHouse and Postgres: local and cloud.",
"homepage": "https://github.com/ClickHouse/clickhousectl",
"repository": {
"type": "git",
Expand Down
Loading