MCPcopy
hub / github.com/cacjs/cac / checkUnknownOptions

Method checkUnknownOptions

src/command.ts:273–289  ·  view source on GitHub ↗

* Check if the parsed options contain any unknown options * * Exit and output error when true

()

Source from the content-addressed store, hash-verified

271 * Exit and output error when true
272 */
273 checkUnknownOptions(): void {
274 const { options, globalCommand } = this.cli
275
276 if (!this.config.allowUnknownOptions) {
277 for (const name of Object.keys(options)) {
278 if (
279 name !== '--' &&
280 !this.hasOption(name) &&
281 !globalCommand.hasOption(name)
282 ) {
283 throw new CACError(
284 `Unknown option \`${name.length > 1 ? `--${name}` : `-${name}`}\``,
285 )
286 }
287 }
288 }
289 }
290
291 /**
292 * Check if the required string-type options exist

Callers 1

runMatchedCommandMethod · 0.80

Calls 1

hasOptionMethod · 0.95

Tested by

no test coverage detected