Skip to content

Commit 64b8756

Browse files
committed
refactor: move key commands under auth group and fix help consistency
Related to https://gitlab.com/postgres-ai/platform/-/issues/346 ## Summary - Reorganize CLI by moving `show-key` and `remove-key` commands under the `auth` command group - Convert `auth` from a standalone command to a command group with `login` as the default subcommand - Remove deprecated `add-key` command (use `auth --set-key` instead) - Fix inconsistent help text capitalization ("Prepare" → "prepare") ## Changes **Before:** | Command | Description | |---------|-------------| | `auth` | authenticate via browser (OAuth) or store API key directly | | `add-key` | store API key | | `show-key` | show API key (masked) | | `remove-key` | remove API key | **After:** | Command | Description | |---------|-------------| | `auth` | authentication and API key management | | `auth login` | authenticate via browser (OAuth) or store API key directly | | `auth show-key` | show API key (masked) | | `auth remove-key` | remove API key | ## Usage - `pgai auth` — runs OAuth login flow (default) - `pgai auth --set-key <key>` — store API key directly - `pgai auth show-key` — show masked API key - `pgai auth remove-key` — remove API key
1 parent 08f1e7d commit 64b8756

1 file changed

Lines changed: 7 additions & 14 deletions

File tree

cli/bin/postgres-ai.ts

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ program
204204

205205
program
206206
.command("prepare-db [conn]")
207-
.description("Prepare database for monitoring: create monitoring user, required view(s), and grant permissions (idempotent)")
207+
.description("prepare database for monitoring: create monitoring user, required view(s), and grant permissions (idempotent)")
208208
.option("--db-url <url>", "PostgreSQL connection URL (admin) to run the setup against (deprecated; pass it as positional arg)")
209209
.option("-h, --host <host>", "PostgreSQL host (psql-like)")
210210
.option("-p, --port <port>", "PostgreSQL port (psql-like)")
@@ -1534,8 +1534,10 @@ targets
15341534
});
15351535

15361536
// Authentication and API key management
1537-
program
1538-
.command("auth")
1537+
const auth = program.command("auth").description("authentication and API key management");
1538+
1539+
auth
1540+
.command("login", { isDefault: true })
15391541
.description("authenticate via browser (OAuth) or store API key directly")
15401542
.option("--set-key <key>", "store API key directly without OAuth flow")
15411543
.option("--port <port>", "local callback server port (default: random)", parseInt)
@@ -1779,16 +1781,7 @@ program
17791781
}
17801782
});
17811783

1782-
program
1783-
.command("add-key <apiKey>")
1784-
.description("store API key (deprecated: use 'auth --set-key' instead)")
1785-
.action(async (apiKey: string) => {
1786-
console.warn("Warning: 'add-key' is deprecated. Use 'auth --set-key <key>' instead.\n");
1787-
config.writeConfig({ apiKey });
1788-
console.log(`API key saved to ${config.getConfigPath()}`);
1789-
});
1790-
1791-
program
1784+
auth
17921785
.command("show-key")
17931786
.description("show API key (masked)")
17941787
.action(async () => {
@@ -1806,7 +1799,7 @@ program
18061799
console.log(`Config location: ${config.getConfigPath()}`);
18071800
});
18081801

1809-
program
1802+
auth
18101803
.command("remove-key")
18111804
.description("remove API key")
18121805
.action(async () => {

0 commit comments

Comments
 (0)