New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@boost/args

Package Overview
Dependencies
Maintainers
1
Versions
30
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@boost/args - npm Package Compare versions

Comparing version 2.1.0 to 2.2.0

12

CHANGELOG.md

@@ -6,2 +6,14 @@ # Change Log

## 2.2.0 - 2020-09-15
#### 🚀 Updates
- Add support for `loose` mode. (#114) ([fc2210d](https://github.com/milesj/boost/commit/fc2210d)), closes [#114](https://github.com/milesj/boost/issues/114)
**Note:** Version bump only for package @boost/args
## 2.1.0 - 2020-08-17

@@ -8,0 +20,0 @@

2

lib/helpers/expandShortOption.d.ts

@@ -5,3 +5,3 @@ import { AliasMap, ShortOptionName, LongOptionName } from '../types';

*/
export default function expandShortOption(short: ShortOptionName, map: AliasMap): LongOptionName;
export default function expandShortOption(short: ShortOptionName, map: AliasMap, loose: boolean): LongOptionName;
//# sourceMappingURL=expandShortOption.d.ts.map

@@ -5,3 +5,3 @@ import { AliasMap, OptionConfigMap, OptionMap } from '../types';

*/
export default function processShortOptionGroup(group: string, configs: OptionConfigMap, options: OptionMap, map: AliasMap): void;
export default function processShortOptionGroup(group: string, configs: OptionConfigMap, options: OptionMap, map: AliasMap, loose: boolean): void;
//# sourceMappingURL=processShortOptionGroup.d.ts.map

@@ -5,7 +5,9 @@ 'use strict';

function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
var internal = require('@boost/internal');
var levenary = _interopDefault(require('levenary'));
var levenary = require('levenary');
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
var levenary__default = /*#__PURE__*/_interopDefaultLegacy(levenary);
function mapToStringList(value) {

@@ -135,4 +137,8 @@ if (!Array.isArray(value)) {

*/
function expandShortOption(short, map) {
function expandShortOption(short, map, loose) {
if (!map[short]) {
if (loose) {
return short;
}
throw new ArgsError('SHORT_UNKNOWN', [short]);

@@ -320,11 +326,13 @@ }

*/
function processShortOptionGroup(group, configs, options, map) {
function processShortOptionGroup(group, configs, options, map, loose) {
group.split('').forEach(short => {
const name = expandShortOption(short, map);
const config = configs[name];
const name = expandShortOption(short, map, loose);
const config = configs[name]; // Loose mode, always be a flag
if (!config || config.type === 'string') {
throw new ArgsError('GROUP_UNSUPPORTED_TYPE'); // Flag
if (loose && !config) {
options[name] = true; // Unknown option
} else if (!config || config.type === 'string') {
throw new ArgsError('GROUP_UNSUPPORTED_TYPE'); // Boolean option, flag
} else if (config.type === 'boolean') {
options[name] = true; // Number counter
options[name] = true; // Number option, counter
} else if (config.type === 'number') {

@@ -387,3 +395,3 @@ if (config.count) {

checkUnknownOption(option) {
const guess = levenary(option, Object.keys(this.options));
const guess = levenary__default['default'](option, Object.keys(this.options));

@@ -544,2 +552,3 @@ if (guess) {

commands: commandConfigs = [],
loose: looseMode = false,
options: optionConfigs,

@@ -563,12 +572,24 @@ params: paramConfigs = [],

return;
} // Set an unknown value
}
const {
name,
value,
finalValue
} = currentScope; // Support loose mode
if (currentScope.unknown) {
if (looseMode) {
if (value === undefined) {
options[name] = !currentScope.negated;
} else {
options[name] = finalValue;
} // Set an unknown value
} else if (currentScope.unknown) {
if (allowUnknown) {
unknown[currentScope.name] = currentScope.value === undefined ? DEFAULT_STRING_VALUE : String(currentScope.finalValue);
unknown[name] = value === undefined ? DEFAULT_STRING_VALUE : String(finalValue);
} // Set and cast value if defined
} else if (currentScope.value !== undefined) {
options[currentScope.name] = currentScope.finalValue;
} else if (value !== undefined) {
options[name] = finalValue;
}

@@ -632,6 +653,6 @@

checker.checkNoInlineValue(inlineValue);
processShortOptionGroup(optionName.slice(1), optionConfigs, options, mapping);
processShortOptionGroup(optionName.slice(1), optionConfigs, options, mapping, looseMode);
continue; // Short option "-f"
} else if (isShortOption(optionName)) {
optionName = expandShortOption(optionName.slice(1), mapping); // Long option "--foo"
optionName = expandShortOption(optionName.slice(1), mapping, looseMode); // Long option "--foo"
} else if (isLongOption(optionName)) {

@@ -644,3 +665,3 @@ optionName = optionName.slice(2);

if (scope.unknown && !allowUnknown) {
if (scope.unknown && !allowUnknown && !looseMode) {
checker.checkUnknownOption(arg); // Flag found, so set value immediately and discard scope

@@ -647,0 +668,0 @@ } else if (scope.flag) {

@@ -17,4 +17,22 @@ export declare type Argv = string[];

export declare type InferParamConfig<T> = T extends PrimitiveType ? Param<T> : never;
export declare type MapParamConfig<T extends PrimitiveType[]> = T extends [infer A, infer B, infer C, infer D, infer E] ? [InferParamConfig<A>, InferParamConfig<B>, InferParamConfig<C>, InferParamConfig<D>, InferParamConfig<E>] : T extends [infer A, infer B, infer C, infer D] ? [InferParamConfig<A>, InferParamConfig<B>, InferParamConfig<C>, InferParamConfig<D>] : T extends [infer A, infer B, infer C] ? [InferParamConfig<A>, InferParamConfig<B>, InferParamConfig<C>] : T extends [infer A, infer B] ? [InferParamConfig<A>, InferParamConfig<B>] : T extends [infer A] ? [InferParamConfig<A>] : T extends ArgList ? Param<string>[] : never;
export declare type MapParamType<T extends PrimitiveType[]> = T extends [infer A, infer B, infer C, infer D, infer E] ? [A, B, C, D, E, ...ArgList] : T extends [infer A, infer B, infer C, infer D] ? [A, B, C, D, ...ArgList] : T extends [infer A, infer B, infer C] ? [A, B, C, ...ArgList] : T extends [infer A, infer B] ? [A, B, ...ArgList] : T extends [infer A] ? [A, ...ArgList] : T extends ArgList ? ArgList : never;
export declare type MapParamConfig<T extends PrimitiveType[]> = T extends [
infer A,
infer B,
infer C,
infer D,
infer E
] ? [
InferParamConfig<A>,
InferParamConfig<B>,
InferParamConfig<C>,
InferParamConfig<D>,
InferParamConfig<E>
] : T extends [infer A, infer B, infer C, infer D] ? [InferParamConfig<A>, InferParamConfig<B>, InferParamConfig<C>, InferParamConfig<D>] : T extends [infer A, infer B, infer C] ? [InferParamConfig<A>, InferParamConfig<B>, InferParamConfig<C>] : T extends [infer A, infer B] ? [InferParamConfig<A>, InferParamConfig<B>] : T extends [infer A] ? [InferParamConfig<A>] : T extends ArgList ? Param<string>[] : never;
export declare type MapParamType<T extends PrimitiveType[]> = T extends [
infer A,
infer B,
infer C,
infer D,
infer E
] ? [A, B, C, D, E, ...ArgList] : T extends [infer A, infer B, infer C, infer D] ? [A, B, C, D, ...ArgList] : T extends [infer A, infer B, infer C] ? [A, B, C, ...ArgList] : T extends [infer A, infer B] ? [A, B, ...ArgList] : T extends [infer A] ? [A, ...ArgList] : T extends ArgList ? ArgList : never;
export declare type InferOptionConfig<T> = T extends boolean ? Flag : T extends number[] | string[] ? MultipleOption<T> : T extends number | string ? SingleOption<T> : never;

@@ -34,8 +52,11 @@ export declare type MapOptionConfig<T extends object> = {

}
export interface ParserOptions<O extends object, P extends PrimitiveType[] = ArgList> {
export interface ParserSettings {
loose?: boolean;
unknown?: boolean;
variadic?: boolean;
}
export interface ParserOptions<O extends object, P extends PrimitiveType[] = ArgList> extends ParserSettings {
commands?: string[] | CommandChecker;
options: MapOptionConfig<O>;
params?: MapParamConfig<P>;
unknown?: boolean;
variadic?: boolean;
}

@@ -42,0 +63,0 @@ export interface Config {

{
"name": "@boost/args",
"version": "2.1.0",
"version": "2.2.0",
"release": "1594765247526",

@@ -30,3 +30,3 @@ "description": "A convention based argument parsing and formatting library, with strict validation checks.",

},
"gitHead": "7982950ce80d97d1815234ee0d66b5dc4ac3a843"
"gitHead": "cb8ff01f674543255334eb8c3d9a85c1b6dbc790"
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc