@boost/args
Advanced tools
Comparing version 1.2.1 to 1.3.0
@@ -6,2 +6,20 @@ # Change Log | ||
## 1.3.0 - 2020-04-08 | ||
#### 🚀 Updates | ||
- Added option categories. ([455e03b](https://github.com/milesj/boost/commit/455e03b)) | ||
- Properly support default values for params. ([e7fca74](https://github.com/milesj/boost/commit/e7fca74)) | ||
#### ⚙️ Types | ||
- Add `category` to `Command`. ([214be93](https://github.com/milesj/boost/commit/214be93)) | ||
- Removed `default` from `Param`. ([8c96605](https://github.com/milesj/boost/commit/8c96605)) | ||
**Note:** Version bump only for package @boost/args | ||
### 1.2.1 - 2020-03-22 | ||
@@ -8,0 +26,0 @@ |
@@ -20,2 +20,3 @@ import ParseError from './ParseError'; | ||
validateParamOrder(configs: ParamConfig[]): void; | ||
validateRequiredParamNoDefault(config: ParamConfig): void; | ||
validateUniqueShortName(option: LongOptionName, short: ShortOptionName, map: AliasMap): void; | ||
@@ -22,0 +23,0 @@ logFailureError(module: string, args?: unknown[]): void; |
@@ -110,2 +110,7 @@ "use strict"; | ||
} | ||
validateRequiredParamNoDefault(config) { | ||
if (config.required && config.default !== undefined) { | ||
this.logInvalidError('AG_PARAM_REQUIRED_NO_DEFAULT', [config.label]); | ||
} | ||
} | ||
validateUniqueShortName(option, short, map) { | ||
@@ -112,0 +117,0 @@ if (map[short]) { |
@@ -83,2 +83,5 @@ "use strict"; | ||
}, | ||
onParam(config) { | ||
checker.validateRequiredParamNoDefault(config); | ||
}, | ||
}); | ||
@@ -167,2 +170,10 @@ // Process each argument | ||
commitScope(); | ||
// Fill missing params | ||
for (let i = params.length; i < paramConfigs.length; i += 1) { | ||
const config = paramConfigs[i]; | ||
if (config.required) { | ||
break; | ||
} | ||
params.push(getDefaultValue_1.default(config)); | ||
} | ||
// Run final checks | ||
@@ -169,0 +180,0 @@ mapParserOptions_1.default(parserOptions, options, params, { |
@@ -45,2 +45,3 @@ export declare type Argv = string[]; | ||
export interface Command extends Config { | ||
category?: string; | ||
usage?: string | string[]; | ||
@@ -55,2 +56,3 @@ } | ||
export interface Option<T extends ValueType> extends Arg<T> { | ||
category?: string; | ||
short?: ShortOptionName; | ||
@@ -75,2 +77,6 @@ } | ||
} | ||
export interface Category { | ||
name: string; | ||
weight?: number; | ||
} | ||
export declare type OptionConfig = Option<any> & { | ||
@@ -77,0 +83,0 @@ arity?: number; |
{ | ||
"name": "@boost/args", | ||
"version": "1.2.1", | ||
"version": "1.3.0", | ||
"description": "A type-safe and convention based argument parsing library, with strict validation checks.", | ||
@@ -29,3 +29,3 @@ "keywords": [ | ||
}, | ||
"gitHead": "fe9903f8a80ae0ad19cc9fd9e51ccbd47e94356e" | ||
"gitHead": "d6808ae43c4baeee8522850ffa8faa29784fbe8c" | ||
} |
@@ -13,2 +13,3 @@ { | ||
"AG_PARAM_REQUIRED": "Param \"%s\" is required but value is undefined.", | ||
"AG_PARAM_REQUIRED_NO_DEFAULT": "Required param \"%s\" has a default value, which is not allowed.", | ||
"AG_SHORT_DEFINED": "Short option \"%s\" has already been defined for \"%s\".", | ||
@@ -15,0 +16,0 @@ "AG_SHORT_SINGLE_CHAR": "Short option \"%s\" may only be a single letter.", |
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
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
59132
936