@rebasepro/cli 0.13.1-canary.g06dbe5b → 0.13.1-canary.g1bf9303

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -193,6 +193,22 @@ export declare function printJson(value: unknown): void;
193
193
  * call is what guarantees a command can never print a table AND a JSON blob.
194
194
  */
195
195
  export declare function emit(human: () => void, json: unknown): void;
196
+ /**
197
+ * Print a help page — the human one, or a machine-readable description of the
198
+ * same command in JSON mode.
199
+ *
200
+ * `--help` is the one place where "stdout is not a TTY" is a weak signal: a
201
+ * person runs `rebase cloud db --help | less` and wants the page. But the rule
202
+ * this family promises is that stdout carries one JSON value whenever it is not
203
+ * a terminal, and a help page is the easiest possible thing to describe
204
+ * structurally — so rather than carve out an exception, help answers the same
205
+ * question in the reader's own language. For an agent, `--help` piped is then a
206
+ * discovery call rather than 60 lines of ANSI to scrape.
207
+ *
208
+ * `env` shipped this shape first, alone; this generalises it so every group
209
+ * answers the same way.
210
+ */
211
+ export declare function emitHelp(command: string, actions: string[], human: () => void, extra?: Record<string, unknown>): void;
196
212
  /**
197
213
  * Print a warning (+ optional hint) — in every output mode, always to stderr.
198
214
  *
@@ -213,7 +229,22 @@ export declare function emit(human: () => void, json: unknown): void;
213
229
  * is for whoever reads the transcript afterwards.
214
230
  */
215
231
  export declare function warn(message: string, hint?: string): void;
216
- /** Print an error (+ optional hint) and exit non-zero. Never returns. */
232
+ /**
233
+ * Print an error (+ optional hint) and exit non-zero. Never returns.
234
+ *
235
+ * `code` is the field a caller branches on, and it defaults to `"error"` rather
236
+ * than `null`. An envelope whose only machine-readable field is null is not
237
+ * machine-readable — `{"error":{"message":"No project specified…","code":null}}`
238
+ * forced the very substring-matching on `message` that the envelope exists to
239
+ * make unnecessary, and `message` is the field most likely to be reworded.
240
+ *
241
+ * `"error"` is deliberately a poor code: it says "this refusal has not been
242
+ * classified yet" without ever being absent. Anything a caller might plausibly
243
+ * want to distinguish — `usage`, `not_found`, `unauthenticated` — passes a real
244
+ * one. Codes are part of the CLI's contract once shipped; see
245
+ * `cloud-reporting.test.ts`, which pins the ones commands are documented to
246
+ * return.
247
+ */
217
248
  export declare function fail(message: string, hint?: string, code?: string): never;
218
249
  /**
219
250
  * Confirm a destructive/irreversible action, respecting non-interactive use.
@@ -227,6 +258,21 @@ export declare function confirmDestructive(opts: {
227
258
  yes: boolean;
228
259
  prompt: string;
229
260
  }): Promise<void>;
261
+ /**
262
+ * Refuse, rather than prompt, when there is nobody to answer.
263
+ *
264
+ * `confirmDestructive` has always done this for yes/no confirmations. The
265
+ * *value* prompts had no such guard: `cloud login`, `cloud link`, `cloud use`,
266
+ * `cloud orgs create` and `cloud db create` all called `inquirer.prompt`
267
+ * unconditionally, so piping any of them — which is how an agent runs every
268
+ * command in this family — parked the process on a prompt reading from a stdin
269
+ * that was never going to produce a line. A hang is the worst failure mode
270
+ * available here: no output, no exit code, nothing to retry on.
271
+ *
272
+ * @param what what the prompt would have asked for, e.g. "an email and password"
273
+ * @param flags the flags that supply it non-interactively
274
+ */
275
+ export declare function requireInteractive(what: string, flags: string): void;
230
276
  /**
231
277
  * Resolve one cloud command's flags and ARGUMENTS from the full `process.argv`.
232
278
  *
@@ -285,7 +331,40 @@ export declare function parseCloudArgs<S extends arg.Spec>(opts: {
285
331
  flags: arg.Result<S & typeof GLOBAL_CLOUD_FLAGS>;
286
332
  positionals: string[];
287
333
  };
334
+ /**
335
+ * Announce an outcome — "Logged in as …", "Deleted project …".
336
+ *
337
+ * On **stderr**, in both modes. It reads like a result and is not one: the
338
+ * result is the JSON value (or the table) on stdout, and every JSON payload in
339
+ * this family already carries `success: true`. Leaving this on stdout meant a
340
+ * successful `rebase cloud link | jq` was handed a green tick followed by an
341
+ * object — one stream, two syntaxes, and only the second parseable.
342
+ *
343
+ * It stays visible in JSON mode, unlike `note`: an agent that got a `success`
344
+ * line on a command it expected to refuse has learned something.
345
+ */
288
346
  export declare function success(message: string): void;
347
+ /**
348
+ * Narrate progress, or point at the next step — "Signing in to …", "Redeploy
349
+ * for the tenant to pick this up".
350
+ *
351
+ * stderr, and **suppressed entirely in JSON mode**. This is the one helper that
352
+ * a mode may silence, and the distinction from `warn` is worth keeping sharp:
353
+ *
354
+ * - A warning is a *condition*. It is as true when piped as when watched, so
355
+ * silencing it hides something the caller would want to know. `warn` never
356
+ * silences.
357
+ * - A note is *hand-holding*. "Next: run `rebase generate-sdk`" tells a person
358
+ * what to type; the agent reading the JSON already has the same information
359
+ * structurally, or does not need it. Printing it anyway is transcript noise.
360
+ *
361
+ * When in doubt it is a warning. The cost of a needless warning is a line; the
362
+ * cost of a swallowed one is the deploy that ejected a project off the managed
363
+ * runtime and said so only to a terminal nobody was looking at.
364
+ */
365
+ export declare function note(message: string, indent?: string): void;
366
+ /** A blank spacer line on the narration stream. No-op in JSON mode. */
367
+ export declare function noteBlank(): void;
289
368
  /** Colorize a deployment / resource status token. */
290
369
  export declare function colorStatus(status: string | undefined): string;
291
370
  /**
@@ -300,7 +379,12 @@ export declare function keyValues(rows: Array<[string, string | null | undefined
300
379
  */
301
380
  export declare function reportError(e: unknown, context: string): never;
302
381
  /**
303
- * Open a URL in the user's default browser (best effort). Always prints the URL
304
- * first so it stays usable over SSH or when no browser is available.
382
+ * Open a URL in the user's default browser (best effort). Always announces the
383
+ * URL first so it stays usable over SSH or when no browser is available.
384
+ *
385
+ * The announcement is narration, not the result — it goes to stderr, and in
386
+ * JSON mode it is silent. Every caller `emit`s the same URL in its payload, so
387
+ * a machine reader gets it from the one place it is guaranteed to be parseable
388
+ * rather than from a line that happens to end in a URL.
305
389
  */
306
390
  export declare function openUrl(target: string, label?: string): void;