feat: add semantic CLI exit codes
This commit is contained in:
1 parent
45eb83a609
commit
a5c0146c8d
5 files changed
+93
-10
No files matched your search
+5
-4
@@ -1,5 +1,6 @@
|
||||
import { booleanOption } from "./parser.js";
|
||||
import type { CliParsedArgs, CliResult, CliRuntime } from "./types.js";
|
||||
import { CliError } from "./errors.js";
|
||||
|
||||
/**
|
||||
* All mutating CLI commands use the same two-step contract:
|
||||
@@ -9,17 +10,17 @@ import type { CliParsedArgs, CliResult, CliRuntime } from "./types.js";
|
||||
* The parsed-argument fallback keeps command handlers easy to unit-test without
|
||||
* requiring every hand-built CliRuntime to include the newer fields.
|
||||
*/
|
||||
export class MutationConfirmationRequired extends Error {
|
||||
export class MutationConfirmationRequired extends CliError {
|
||||
readonly operation: string;
|
||||
readonly nextAction: string;
|
||||
|
||||
constructor(operation: string, nextAction: string) {
|
||||
super(
|
||||
`拒绝执行${operation}:该操作会改变数据。请先使用 --dry-run 预览,确认后追加 --yes(或 --confirm)。\n下一步:${nextAction}`
|
||||
`拒绝执行${operation}:该操作会改变数据。请先使用 --dry-run 预览,确认后追加 --yes(或 --confirm)。`,
|
||||
10,
|
||||
nextAction
|
||||
);
|
||||
this.name = "MutationConfirmationRequired";
|
||||
this.operation = operation;
|
||||
this.nextAction = nextAction;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user