/*** CLI exit helpers for subcommand handlers.** Consolidates the 4-5 line "print + lint-suppress + exit" block that was* copy-pasted ~60 times across `claude mcp *` / `claude plugin *` handlers.* The `: never` return type lets TypeScript narrow control flow at call sites* without a trailing `return`.*//* eslint-disable custom-rules/no-process-exit -- centralized CLI exit point */// `return undefined as never` (not a post-exit throw) — tests spy on// process.exit and let it return. Call sites write `return cliError(...)`// where subsequent code would dereference narrowed-away values under mock.// cliError uses console.error (tests spy on console.error); cliOk uses// process.stdout.write (tests spy on process.stdout.write — Bun's console.log// doesn't route through a spied process.stdout.write)./** Write an error message to stderr (if given) and exit with code 1. */export function cliError(msg?: string): never {// biome-ignore lint/suspicious/noConsole: centralized CLI error outputif (msg) console.error(msg)process.exit(1)return undefined as never}/** Write a message to stdout (if given) and exit with code 0. */export function cliOk(msg?: string): never {if (msg) process.stdout.write(msg + '\n')process.exit(0)return undefined as never}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。