Skip to content
Merged
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
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,12 @@ clickhousectl local server stop-all # Stop all running ser

# Remove a stopped server and its data
clickhousectl local server remove test

# Write connection env vars to .env file
clickhousectl local server dotenv # From "default" server → .env
clickhousectl local server dotenv --name dev # From "dev" server → .env
clickhousectl local server dotenv --local # Write to .env.local instead
clickhousectl local server dotenv --user default --password secret --database mydb # Include credentials
```

**Server naming:** Without `--name`, the first server is called "default". If "default" is already running, a random name is generated (e.g. "bold-crane"). Use `--name` for stable identities you can start/stop repeatedly.
Expand Down
32 changes: 32 additions & 0 deletions src/local/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -214,4 +214,36 @@ CONTEXT FOR AGENTS:
/// Name of the server to remove
name: String,
},

/// Write ClickHouse connection env vars to a .env file
#[command(after_help = "\
CONTEXT FOR AGENTS:
Writes CLICKHOUSE_HOST, CLICKHOUSE_PORT, and CLICKHOUSE_HTTP_PORT into a .env file
(or .env.local with --local) based on a running server's actual connection details.
Optionally includes CLICKHOUSE_USER, CLICKHOUSE_PASSWORD, and CLICKHOUSE_DATABASE when
the corresponding flags are provided.
If the file already exists, existing CLICKHOUSE_* vars are replaced in-place. Otherwise the file is created.
Useful for configuring apps that read from dotenv files.
Related: `clickhousectl local server start` to start a server, `clickhousectl local server list` to see servers.")]
Dotenv {
/// Server name (default: "default")
#[arg(long)]
name: Option<String>,

/// Write to .env.local instead of .env
#[arg(long)]
local: bool,

/// Include CLICKHOUSE_USER with this value
#[arg(long)]
user: Option<String>,

/// Include CLICKHOUSE_PASSWORD with this value
#[arg(long)]
password: Option<String>,

/// Include CLICKHOUSE_DATABASE with this value
#[arg(long)]
database: Option<String>,
},
}
Loading
Loading