@hyperone/cli-framework
Advanced tools
Comparing version 1.0.8 to 1.0.12
@@ -6,2 +6,3 @@ | ||
import Command from './command'; | ||
import { NotFoundCommandError, AlreadyLoadedError } from '@hyperone/cli-framework/error'; | ||
@@ -59,3 +60,3 @@ class Category extends Command { | ||
if (this.loaded) { | ||
throw new Error('No late to add new lazy command'); | ||
throw new AlreadyLoadedError('No late to add new lazy command'); | ||
} | ||
@@ -94,11 +95,7 @@ this.lazyCommands.push(cmd); | ||
} | ||
const result = meant(allOpts.command, this.commands.map(x => x.name)); | ||
const msg = [ | ||
`Error: unknown command "${allOpts.command}" for "${this.name}".`, | ||
]; | ||
if (result.length > 0) { | ||
msg.push('Did you mean this?'); | ||
msg.push(...result.map(x => `\t${x}`)); | ||
} | ||
return msg.join('\n'); | ||
const suggestion = meant(allOpts.command, this.commands.map(x => x.name)); | ||
throw new NotFoundCommandError( | ||
`Unknown command "${allOpts.command}" for "${this.getFullName()}".`, | ||
suggestion | ||
); | ||
} | ||
@@ -105,0 +102,0 @@ |
@@ -6,2 +6,3 @@ | ||
import { resolvePointer, serializeValue } from './utils'; | ||
import { UnknownOptionError} from './error'; | ||
@@ -97,16 +98,8 @@ class Command { | ||
const option = opts._unknown[0]; | ||
const subname = options.map(x => `--${x.name}`); | ||
const result = meant(option, subname); | ||
const msg = [ | ||
`Error: unknown option "${option}" for "${this.name}".`, | ||
]; | ||
if (result.length > 0) { | ||
msg.push('Did you mean this?'); | ||
msg.push(...result.map(x => `\t${x}`)); | ||
} | ||
return msg.join('\n'); | ||
const suggestion = meant(option, options.map(x => `--${x.name}`)); | ||
throw new UnknownOptionError(`Unknown parameter "${option}" for "${this.getFullName()}"`, suggestion); | ||
} | ||
const missing = options.filter(x => x.required && typeof allOpts[x.name] == 'undefined').map(x => `--${x.name}`); | ||
if (missing.length > 0) { | ||
return `Argument missing: ${missing.join(', ')}`; | ||
throw new UnknownOptionError(`Parameter missing: ${missing.join(', ')}`, missing); | ||
} | ||
@@ -113,0 +106,0 @@ let p = Promise.resolve(); |
{ | ||
"name": "@hyperone/cli-framework", | ||
"version": "1.0.8", | ||
"version": "1.0.12", | ||
"description": "", | ||
@@ -20,3 +20,3 @@ "main": "index.js", | ||
}, | ||
"gitHead": "a3a4d4cf6ce542757ec9adbc129f9b93bea9380e" | ||
"gitHead": "0e4a91ccb71944831bdce5a123e2c66db02f8d4c" | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
12011
8
354