From e332fa4a83d36605771844745738c001f276b390 Mon Sep 17 00:00:00 2001 From: Yoshiya Hinosawa Date: Wed, 29 Nov 2023 15:42:58 +0900 Subject: fix(ext/node): add util.parseArgs (#21342) --- ext/node/polyfills/internal/errors.ts | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) (limited to 'ext/node/polyfills/internal/errors.ts') diff --git a/ext/node/polyfills/internal/errors.ts b/ext/node/polyfills/internal/errors.ts index 7f7ce9d3a..8d10e1857 100644 --- a/ext/node/polyfills/internal/errors.ts +++ b/ext/node/polyfills/internal/errors.ts @@ -2472,6 +2472,36 @@ export class ERR_PACKAGE_PATH_NOT_EXPORTED extends NodeError { } } +export class ERR_PARSE_ARGS_INVALID_OPTION_VALUE extends NodeTypeError { + constructor(x: string) { + super("ERR_PARSE_ARGS_INVALID_OPTION_VALUE", x); + } +} + +export class ERR_PARSE_ARGS_UNEXPECTED_POSITIONAL extends NodeTypeError { + constructor(x: string) { + super( + "ERR_PARSE_ARGS_UNEXPECTED_POSITIONAL", + `Unexpected argument '${x}'. This ` + + `command does not take positional arguments`, + ); + } +} + +export class ERR_PARSE_ARGS_UNKNOWN_OPTION extends NodeTypeError { + constructor(option, allowPositionals) { + const suggestDashDash = allowPositionals + ? ". To specify a positional " + + "argument starting with a '-', place it at the end of the command after " + + `'--', as in '-- ${JSONStringify(option)}` + : ""; + super( + "ERR_PARSE_ARGS_UNKNOWN_OPTION", + `Unknown option '${option}'${suggestDashDash}`, + ); + } +} + export class ERR_INTERNAL_ASSERTION extends NodeError { constructor(message?: string) { const suffix = "This is caused by either a bug in Node.js " + -- cgit v1.2.3