diff --git a/README.md b/README.md index e1b572ef..fe8b05b7 100644 --- a/README.md +++ b/README.md @@ -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? diff --git a/crates/clickhousectl/Cargo.toml b/crates/clickhousectl/Cargo.toml index 4c9f4648..cd4072f0 100644 --- a/crates/clickhousectl/Cargo.toml +++ b/crates/clickhousectl/Cargo.toml @@ -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 diff --git a/crates/clickhousectl/src/cli.rs b/crates/clickhousectl/src/cli.rs index 73d91d45..fcd0e54b 100644 --- a/crates/clickhousectl/src/cli.rs +++ b/crates/clickhousectl/src/cli.rs @@ -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 ` - Install the ClickHouse agent skills: `clickhousectl skills --agent claude`" + Install the ClickHouse and Postgres agent skills: `clickhousectl skills --agent claude`" }; } @@ -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') @@ -79,7 +79,8 @@ CONTEXT FOR AGENTS: Outside a project they use the current directory, and server starts create `.clickhouse/` there. CLICKHOUSECTL_PROJECT_DIR= skips discovery: 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 @@ -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), /// Install ClickHouse agent skills into supported coding agents diff --git a/crates/clickhousectl/src/local/cli.rs b/crates/clickhousectl/src/local/cli.rs index 212b17b5..a8ab428c 100644 --- a/crates/clickhousectl/src/local/cli.rs +++ b/crates/clickhousectl/src/local/cli.rs @@ -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 diff --git a/crates/clickhousectl/src/search.rs b/crates/clickhousectl/src/search.rs index 5d6d24dc..ab902ee9 100644 --- a/crates/clickhousectl/src/search.rs +++ b/crates/clickhousectl/src/search.rs @@ -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. @@ -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 = real_index() diff --git a/npm/package.json b/npm/package.json index 456acddb..53fb7a6e 100644 --- a/npm/package.json +++ b/npm/package.json @@ -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",