command-line-interface
Advanced tools
Comparing version 4.0.21 to 4.0.22
@@ -5,5 +5,3 @@ "use strict"; | ||
const help_1 = require("./commands/help"); | ||
// eslint-disable-next-line @typescript-eslint/ban-types | ||
const addHelpCommandToCli = function ({ rootCommand }) { | ||
var _a; | ||
return { | ||
@@ -18,3 +16,3 @@ name: rootCommand.name, | ||
subcommands: { | ||
...(_a = rootCommand.subcommands) !== null && _a !== void 0 ? _a : {}, | ||
...rootCommand.subcommands, | ||
help: help_1.helpCommand | ||
@@ -21,0 +19,0 @@ }, |
@@ -1,16 +0,16 @@ | ||
declare const CommandNotFound_base: import("defekt/build/lib/ErrorConstructor").ErrorConstructor<"CommandNotFound">; | ||
declare const CommandNotFound_base: import("defekt/build/lib/CustomErrorConstructor").CustomErrorConstructor<"CommandNotFound">; | ||
declare class CommandNotFound extends CommandNotFound_base { | ||
} | ||
declare const InvalidOperation_base: import("defekt/build/lib/ErrorConstructor").ErrorConstructor<"InvalidOperation">; | ||
declare const InvalidOperation_base: import("defekt/build/lib/CustomErrorConstructor").CustomErrorConstructor<"InvalidOperation">; | ||
declare class InvalidOperation extends InvalidOperation_base { | ||
} | ||
declare const NoSuggestionAvailable_base: import("defekt/build/lib/ErrorConstructor").ErrorConstructor<"NoSuggestionAvailable">; | ||
declare const NoSuggestionAvailable_base: import("defekt/build/lib/CustomErrorConstructor").CustomErrorConstructor<"NoSuggestionAvailable">; | ||
declare class NoSuggestionAvailable extends NoSuggestionAvailable_base { | ||
} | ||
declare const OptionInvalid_base: import("defekt/build/lib/ErrorConstructor").ErrorConstructor<"OptionInvalid">; | ||
declare const OptionInvalid_base: import("defekt/build/lib/CustomErrorConstructor").CustomErrorConstructor<"OptionInvalid">; | ||
declare class OptionInvalid extends OptionInvalid_base { | ||
} | ||
declare const OptionMissing_base: import("defekt/build/lib/ErrorConstructor").ErrorConstructor<"OptionMissing">; | ||
declare const OptionMissing_base: import("defekt/build/lib/CustomErrorConstructor").CustomErrorConstructor<"OptionMissing">; | ||
declare class OptionMissing extends OptionMissing_base { | ||
} | ||
export { CommandNotFound, InvalidOperation, NoSuggestionAvailable, OptionInvalid, OptionMissing }; |
@@ -5,16 +5,16 @@ "use strict"; | ||
const defekt_1 = require("defekt"); | ||
class CommandNotFound extends defekt_1.defekt({ code: 'CommandNotFound' }) { | ||
class CommandNotFound extends (0, defekt_1.defekt)({ code: 'CommandNotFound' }) { | ||
} | ||
exports.CommandNotFound = CommandNotFound; | ||
class InvalidOperation extends defekt_1.defekt({ code: 'InvalidOperation' }) { | ||
class InvalidOperation extends (0, defekt_1.defekt)({ code: 'InvalidOperation' }) { | ||
} | ||
exports.InvalidOperation = InvalidOperation; | ||
class NoSuggestionAvailable extends defekt_1.defekt({ code: 'NoSuggestionAvailable' }) { | ||
class NoSuggestionAvailable extends (0, defekt_1.defekt)({ code: 'NoSuggestionAvailable' }) { | ||
} | ||
exports.NoSuggestionAvailable = NoSuggestionAvailable; | ||
class OptionInvalid extends defekt_1.defekt({ code: 'OptionInvalid' }) { | ||
class OptionInvalid extends (0, defekt_1.defekt)({ code: 'OptionInvalid' }) { | ||
} | ||
exports.OptionInvalid = OptionInvalid; | ||
class OptionMissing extends defekt_1.defekt({ code: 'OptionMissing' }) { | ||
class OptionMissing extends (0, defekt_1.defekt)({ code: 'OptionMissing' }) { | ||
} | ||
exports.OptionMissing = OptionMissing; |
@@ -8,5 +8,5 @@ "use strict"; | ||
const currentPath = commandPath.slice(0, index + 1); | ||
return getCommandByPath_1.getCommandByPath({ rootCommand, commandPath: currentPath }); | ||
return (0, getCommandByPath_1.getCommandByPath)({ rootCommand, commandPath: currentPath }); | ||
}); | ||
}; | ||
exports.getCommandsByPath = getCommandsByPath; |
@@ -6,4 +6,4 @@ "use strict"; | ||
const getRecommendCommand = function ({ rootCommand }) { | ||
return ({ commandPath }) => recommendCommand_1.recommendCommand({ rootCommand, commandPath }); | ||
return ({ commandPath }) => (0, recommendCommand_1.recommendCommand)({ rootCommand, commandPath }); | ||
}; | ||
exports.getRecommendCommand = getRecommendCommand; |
@@ -31,4 +31,4 @@ "use strict"; | ||
const goodPath = commandPath.slice(0, -1); | ||
const unrecognizedCommand = commandPath[commandPath.length - 1]; | ||
const goodCommand = getCommandByPath_1.getCommandByPath({ rootCommand, commandPath: goodPath }); | ||
const unrecognizedCommand = commandPath.at(-1); | ||
const goodCommand = (0, getCommandByPath_1.getCommandByPath)({ rootCommand, commandPath: goodPath }); | ||
if (goodCommand.subcommands === undefined) { | ||
@@ -35,0 +35,0 @@ throw new errors.NoSuggestionAvailable(); |
@@ -32,6 +32,6 @@ "use strict"; | ||
}; | ||
const extendedRootCommand = addHelpCommandToCli_1.addHelpCommandToCli({ rootCommand }); | ||
const recommendCommand = getRecommendCommand_1.getRecommendCommand({ rootCommand: extendedRootCommand }); | ||
const getUsage = getGetUsage_1.getGetUsage({ rootCommand: extendedRootCommand }); | ||
await runCliRecursive_1.runCliRecursive({ | ||
const extendedRootCommand = (0, addHelpCommandToCli_1.addHelpCommandToCli)({ rootCommand }); | ||
const recommendCommand = (0, getRecommendCommand_1.getRecommendCommand)({ rootCommand: extendedRootCommand }); | ||
const getUsage = (0, getGetUsage_1.getGetUsage)({ rootCommand: extendedRootCommand }); | ||
await (0, runCliRecursive_1.runCliRecursive)({ | ||
command: extendedRootCommand, | ||
@@ -38,0 +38,0 @@ argv, |
@@ -35,3 +35,3 @@ "use strict"; | ||
const optionDefinitions = command.optionDefinitions. | ||
map((optionDefinition) => convertOptionDefinition_1.convertOptionDefinition({ optionDefinition })); | ||
map((optionDefinition) => (0, convertOptionDefinition_1.convertOptionDefinition)({ optionDefinition })); | ||
const optionDefinitionsWithHelp = [ | ||
@@ -42,3 +42,3 @@ ...optionDefinitions, | ||
// eslint-disable-next-line @typescript-eslint/naming-convention | ||
const { _unknown, ...options } = command_line_args_1.default(optionDefinitionsWithHelp, { argv, stopAtFirstUnknown: true }); | ||
const { _unknown, ...options } = (0, command_line_args_1.default)(optionDefinitionsWithHelp, { argv, stopAtFirstUnknown: true }); | ||
if (options.help) { | ||
@@ -50,3 +50,3 @@ // eslint-disable-next-line no-console | ||
try { | ||
validateOptions_1.validateOptions({ options, optionDefinitions: command.optionDefinitions }); | ||
(0, validateOptions_1.validateOptions)({ options, optionDefinitions: command.optionDefinitions }); | ||
} | ||
@@ -95,3 +95,3 @@ catch (ex) { | ||
try { | ||
const { command: subCommandName, argv: subArgv } = command_line_commands_1.default(Object.keys(command.subcommands), | ||
const { command: subCommandName, argv: subArgv } = (0, command_line_commands_1.default)(Object.keys(command.subcommands), | ||
// Pass a copy of the _unknown array, since the commandLineCommands | ||
@@ -98,0 +98,0 @@ // function mutates the parameter in-place. To avoid this, spread it and |
@@ -12,5 +12,5 @@ "use strict"; | ||
const getCommandLineUsageConfiguration = function ({ rootCommand, commandPath }) { | ||
const commandsInPath = getCommandsByPath_1.getCommandsByPath({ rootCommand, commandPath }); | ||
const command = commandsInPath[commandsInPath.length - 1]; | ||
const synopsis = commandsInPath.map((currentCommand) => getCommandSynopsis_1.getCommandSynopsis({ command: currentCommand })).join(' '); | ||
const commandsInPath = (0, getCommandsByPath_1.getCommandsByPath)({ rootCommand, commandPath }); | ||
const command = commandsInPath.at(-1); | ||
const synopsis = commandsInPath.map((currentCommand) => (0, getCommandSynopsis_1.getCommandSynopsis)({ command: currentCommand })).join(' '); | ||
const usage = [ | ||
@@ -30,3 +30,3 @@ { | ||
var _a; | ||
const convertedOptionDefinition = convertOptionDefinition_1.convertOptionDefinition({ optionDefinition }); | ||
const convertedOptionDefinition = (0, convertOptionDefinition_1.convertOptionDefinition)({ optionDefinition }); | ||
return { | ||
@@ -52,3 +52,3 @@ ...convertedOptionDefinition, | ||
header: 'Remarks', | ||
content: [strip_indent_1.default(command.remarks).trim()] | ||
content: [(0, strip_indent_1.default)(command.remarks).trim()] | ||
}); | ||
@@ -55,0 +55,0 @@ } |
@@ -12,6 +12,6 @@ "use strict"; | ||
const requiredOptionsString = requiredOptions. | ||
map((option) => optionToString_1.optionToString({ option })). | ||
map((option) => (0, optionToString_1.optionToString)({ option })). | ||
join(' '); | ||
const optionalOptionsString = optionalOptions. | ||
map((option) => optionToString_1.optionToString({ option })). | ||
map((option) => (0, optionToString_1.optionToString)({ option })). | ||
join(' '); | ||
@@ -27,4 +27,4 @@ let synopsis = command.name; | ||
synopsis += defaultOption.isRequired ? | ||
` ${optionToString_1.optionToString({ option: defaultOption })}` : | ||
` [${optionToString_1.optionToString({ option: defaultOption })}]`; | ||
` ${(0, optionToString_1.optionToString)({ option: defaultOption })}` : | ||
` [${(0, optionToString_1.optionToString)({ option: defaultOption })}]`; | ||
} | ||
@@ -31,0 +31,0 @@ return synopsis; |
@@ -11,6 +11,6 @@ "use strict"; | ||
return ({ commandPath }) => { | ||
const commandLineUsageConfiguration = getCommandLineUsageConfiguration_1.getCommandLineUsageConfiguration({ rootCommand, commandPath }); | ||
return command_line_usage_1.default(commandLineUsageConfiguration); | ||
const commandLineUsageConfiguration = (0, getCommandLineUsageConfiguration_1.getCommandLineUsageConfiguration)({ rootCommand, commandPath }); | ||
return (0, command_line_usage_1.default)(commandLineUsageConfiguration); | ||
}; | ||
}; | ||
exports.getGetUsage = getGetUsage; |
@@ -0,1 +1,8 @@ | ||
## [4.0.22](https://github.com/thenativeweb/command-line-interface/compare/4.0.21...4.0.22) (2022-03-24) | ||
### Bug Fixes | ||
* Update dependencies. ([#431](https://github.com/thenativeweb/command-line-interface/issues/431)) ([e148ba1](https://github.com/thenativeweb/command-line-interface/commit/e148ba1414b3946066dfd2fe1244a8ea7f8f8c0f)) | ||
## [4.0.21](https://github.com/thenativeweb/command-line-interface/compare/4.0.20...4.0.21) (2021-08-15) | ||
@@ -2,0 +9,0 @@ |
import { Command } from './elements/Command'; | ||
import { helpCommand } from './commands/help'; | ||
// eslint-disable-next-line @typescript-eslint/ban-types | ||
const addHelpCommandToCli = function <TOptions extends object> ({ rootCommand }: { | ||
@@ -17,3 +16,3 @@ rootCommand: Command<TOptions>; | ||
subcommands: { | ||
...rootCommand.subcommands ?? {}, | ||
...rootCommand.subcommands, | ||
help: helpCommand | ||
@@ -20,0 +19,0 @@ }, |
import { CommandHandle } from './CommandHandle'; | ||
import { OptionDefinition } from './OptionDefinition'; | ||
// eslint-disable-next-line @typescript-eslint/ban-types | ||
export interface Command<TOptions extends object> { | ||
@@ -6,0 +5,0 @@ name: string; |
import { CommandHandleOptions } from './CommandHandleOptions'; | ||
// eslint-disable-next-line @typescript-eslint/ban-types | ||
export type CommandHandle<TOptions extends object> = (params: CommandHandleOptions<TOptions>) => void | Promise<void>; |
import { CommandPath } from './CommandPath'; | ||
import { GetUsageFn } from './GetUsageFn'; | ||
// eslint-disable-next-line @typescript-eslint/ban-types | ||
export interface CommandHandleOptions<TOptions extends object> { | ||
@@ -6,0 +5,0 @@ options: TOptions; |
@@ -12,3 +12,3 @@ import { Command } from '../elements/Command'; | ||
const goodPath = commandPath.slice(0, -1); | ||
const unrecognizedCommand = commandPath[commandPath.length - 1]; | ||
const unrecognizedCommand = commandPath.at(-1)!; | ||
@@ -15,0 +15,0 @@ const goodCommand = getCommandByPath({ rootCommand, commandPath: goodPath }); |
@@ -14,3 +14,3 @@ import { Command } from '../elements/Command'; | ||
const commandsInPath = getCommandsByPath({ rootCommand, commandPath }); | ||
const command = commandsInPath[commandsInPath.length - 1]; | ||
const command = commandsInPath.at(-1)!; | ||
@@ -17,0 +17,0 @@ const synopsis = commandsInPath.map((currentCommand): string => getCommandSynopsis({ command: currentCommand })).join(' '); |
{ | ||
"name": "command-line-interface", | ||
"version": "4.0.21", | ||
"version": "4.0.22", | ||
"description": "command-line-interface is a foundation for CLI applications.", | ||
@@ -23,2 +23,3 @@ "contributors": [ | ||
], | ||
"private": false, | ||
"main": "build/lib/index.js", | ||
@@ -31,6 +32,6 @@ "types": "build/lib/index.d.ts", | ||
"@types/string-similarity": "4.0.0", | ||
"command-line-args": "5.2.0", | ||
"command-line-args": "5.2.1", | ||
"command-line-commands": "3.0.2", | ||
"command-line-usage": "6.1.1", | ||
"defekt": "7.3.2", | ||
"defekt": "9.1.0", | ||
"string-similarity": "4.0.4", | ||
@@ -40,9 +41,10 @@ "strip-indent": "3.0.0" | ||
"devDependencies": { | ||
"@types/sinon": "10.0.2", | ||
"assertthat": "6.3.11", | ||
"record-stdstreams": "3.0.67", | ||
"roboter": "11.7.8", | ||
"semantic-release-configuration": "2.0.5", | ||
"sinon": "11.1.2" | ||
"@types/sinon": "10.0.11", | ||
"assertthat": "6.5.1", | ||
"record-stdstreams": "3.0.73", | ||
"roboter": "13.0.0", | ||
"semantic-release-configuration": "2.0.7", | ||
"sinon": "13.0.1" | ||
}, | ||
"scripts": {}, | ||
"repository": { | ||
@@ -49,0 +51,0 @@ "type": "git", |
@@ -15,3 +15,6 @@ { | ||
"./**/*.ts" | ||
], | ||
"exclude": [ | ||
"./build" | ||
] | ||
} |
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
88817
87
1472
+ Addedcommand-line-args@5.2.1(transitive)
+ Addeddefekt@9.1.0(transitive)
- Removedcommand-line-args@5.2.0(transitive)
- Removeddefekt@7.3.2(transitive)
Updatedcommand-line-args@5.2.1
Updateddefekt@9.1.0