Dashboard › cli › Distillation
1b37120d-4a95-4504-8752-413e511de1a8["lore_tm_v1_69qdfTXwEOqT_ARlkxQ3FVUrBPw1IMDOM7RyC6rsi04"]
packages/cli/test/lib/help-json.test.ts contains 27 Vitest unit tests for renderJsonHelp, rewriteHelpJsonToHelpCommand, isVersionRequest, and isRecoverableUnknownCommand, imported from ../../src/lib/help.js; the tests use const APP = "sentry".renderJsonHelp suite documents the pure input→output contract of the renderer wired into Stricli’s documentation.renderHelp hook in app.ts; end-to-end routing and scanner-patch behavior is covered separately in scanner-flags.integration.test.ts.renderJsonHelp([APP], []) and renderJsonHelp([APP, "issue", "list"], []) must return undefined when --json is absent so text help is used.renderJsonHelp([APP], ["--json"]) must emit the full command tree as JSON with top-level routes and flags properties, and routes must be an array.renderJsonHelp([APP, "issue", "list"], ["--json"]) must emit command metadata containing path, whose value includes "issue list".renderJsonHelp JSON output must be pretty-printed with 2-space indentation via JSON.stringify(_, null, 2) and end with a trailing newline.renderJsonHelp([APP, "issue", "list"], ["--json", "--fields", "path"]) must support the spaced --fields form and narrow output to exactly the path key.renderJsonHelp([APP, "issue", "list"], ["--json", "--fields=path"]) must support the inline --fields=<value> form and narrow output to exactly the path key.renderJsonHelp([APP, "issue", "list"], ["--json", "--fields", "path,brief"]) must accept comma-separated fields and return exactly the brief and path keys.renderJsonHelp([APP, "monitor", "run"], ["--", "tool", "--json"]) must return undefined; a --json after the -- escape belongs to the wrapped command and must be ignored.renderJsonHelp([APP, "nope"], ["--json"]) must return a JSON error object for an unknown command path.renderJsonHelp([APP, "issue"], ["nope", "--json"]) must return a JSON object with an error containing "nope"; this covers sentry issue nope --help --json, where the scanner forwards nope in unprocessedInputs to the issue group’s default command rather than including it in the route prefix.renderJsonHelp([APP], ["nope", "--json"]) must return a JSON error object for a top-level unknown token.renderJsonHelp([APP, "issue", "list"], ["--org", "acme", "--json"]) must consume "acme" as the spaced value of global flag --org, not treat it as a command-path segment, and return metadata whose path includes "issue list".rewriteHelpJsonToHelpCommand() must return undefined for ["cli", "nope"], ["cli", "nope", "--help"], and ["cli", "nope", "--json"], because none is a combined --help --json request.rewriteHelpJsonToHelpCommand(["cli", "nope", "--help", "--json"]) must rewrite an unknown-command JSON-help request to ["help", "--json", "cli", "nope"].rewriteHelpJsonToHelpCommand(["--json", "cli", "-h"]) must recognize the -h alias, be order-insensitive, and return ["help", "--json", "cli"].rewriteHelpJsonToHelpCommand(["issue", "list", "--help", "--json", "--fields", "path"]) must preserve the spaced field selection and return ["help", "--json", "issue", "list", "--fields", "path"].rewriteHelpJsonToHelpCommand(["--org", "acme", "--log-level", "debug", "cli", "nope", "--help", "--json"]) must drop spaced values "acme" and "debug" for value-taking global flags from the command path and return ["help", "--json", "cli", "nope"].rewriteHelpJsonToHelpCommand(["--org=acme", "cli", "nope", "--help", "--json"]) must drop the inline value-flag form without consuming the following token and return ["help", "--json", "cli", "nope"].rewriteHelpJsonToHelpCommand(["monitor", "run", "--", "tool", "--help", "--json"]) must return undefined, ignoring --help and --json after the -- escape.isVersionRequest(["--version"]), isVersionRequest(["cli", "--version"]), and isVersionRequest(["cli", "nope", "--version"]) must return true; the last case covers recovery in cli.ts when the scanner aborts before consuming an unknown route token.isVersionRequest(["cli", "nope"]) and isVersionRequest([]) must return false when --version is absent.isVersionRequest(["-v"]) must return false; Sentry CLI remaps -v to --verbose, and the scanner patch removes Stricli’s -v=version alias.isVersionRequest(["bash-hook", "--", "--version"]) must return false, ignoring --version after the -- escape.isRecoverableUnknownCommand(["cli", "nope", "--version"]) must return true for a version request.isRecoverableUnknownCommand(["cli", "nope", "--help", "--json"]) must return true even though the final token is --json; this is a regression test for the old guard that checked only argv.at(-1) === "help" and therefore emitted a spurious unknown_command telemetry event.isRecoverableUnknownCommand(["dashboard", "help"]) must return true for a trailing help token.isRecoverableUnknownCommand(["cli", "nope"]) and isRecoverableUnknownCommand(["issue", "listt"]) must return false for genuine unknown commands.