Additions:
Filtering!:
opts.shouldStopParsingFunc(): more information in commit's types.d.ts;
opts.shouldStopParsingStr: more information in commit's types.d.ts;
opts.parseFilterFunc(): more information in commit's types.d.ts;
(tweaked (lookingForFlagVal -> naturalFlagAssignment) to include the flag's type to add onto new argMeta for filtering functions);
isTypeAssignable()
assureValidFlagConfigState(): Now guarantees that flag.config is assigned right after runAutomaticBooleanFlagNegation() in the flag branch of arg handling, skipping the need for other flagConfig lookups (as it would be required in one step or another regardless);
runFlagAssignedValueAssignment(): extracted main code of meta.hasAssignedValue branch into this function (also adjusted to account for flag.isNegated);
internalFlag.isNegated: set by runAutomaticBooleanFlagNegation(), for refactored boolean flag negation handling;
internalFlag.type: extracted flagType assignments into guaranteed
Removals:
internalFlag.lookedupFlagConfig: flag.config is now assured with assureValidFlagConfigState() after runAutomaticBooleanFlagNegation(), and is instead tested against flag.config === null within assureValidFlagConfigState() to avoid repeating getting flag;
Fixes:
expectType(): Removed unused (and broken) null handling from;
validateOrDefaultIfUnset(): Fixed passing through to expectType() when setting the default, breaking if the default type isn't the 'required' type (ie: null value defaults);
opts.lowerCaseFlags now correctly applies to shorthand flags;
flags with an explicit string type now correctly do not apply opts.resolveFlagValueTypes even if enabled;
defined boolean type flags that undergo automatic boolean negation (ie: --no-flag) now correctly resolve if there is an input value after it (bug with a defined flag: `['--no-flag', 'hi'] -> { 'no-flag': 'hi' }`);
Fixed some spelling issues (eg: 2x otps -> opts);
Other:
Copied StringConsumer from OxLib into index.js
Moved stage of runAutomaticBooleanFlagNegation() from beginning of flag post arg handling -> pre flag assignments in arg handling, with a small refactor;
-> Addition of internalFlag.isNegated
Cleaned up and clarified the purpose of isAssignedValueTypeAssignable() -> assignedValueUncastableTypeError() to externalize the check thanks to new isTypeAssignable();
Cleaned up and clarified the purpose of unknownFlag() -> unknownFlagError() to externalize the check;
Main arg handling 'loop' is not a for loop instead of a foreach to allow for a break statement for the new opts.shouldStopParsing* options;
-Note: Other small unmentioned things, and big commit, probably forgot some note-worthy things, mb;
ox-argv-parser
Decently customizable and fairly fast Argv parser in js
Description
Languages
JavaScript
100%