You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently the only way to configure yargs-parser is by the following. (Excuse my mixed syntax)
require('yargs-parser")(args, opts) => Arguments
I propose creating a builder pipeline that allows you to preconfigure your opts before running the command by adding an opts function to the Parser interface
Allows parser to check options ahead of time. This means that if after you create your parser with opts, yargs-parser doesn't have to do any of the setup of validation twice. So if you do myParser("mystring") there is no need to
any of the options pre-processing twice. The first time the args are even referenced on the parser function are like 150 lines of code in:
//Oldwayconstoldway=require('yargs-parser)
oldway("my command",{opts...})//Can't throw opts error because that's breaking change//Warning only happens when parser is used, instead of when options are defined//To make a preconfigured bashlike parserconstparse=require('yargs-parser').opts({...}).bash//Returns (arg: string, opts?: Partial<Options>) =>Arguments//Can immediately throw if your options are invalid, faster debuggingparse("myweird option with a literal \\\" in it")//Is able to skip option validation since it was already done.parse("myweird option with a literal \\\" in it",{additional_opts})//Can't skip validation, but original options will still have thrown error if malformedparse(["my","bunch","of","tokens"])//Compiler error: bash tokenizer expects string, tokenizing tokens makes no sense
These are just a couple of thoughts. Other potential things that could come from this is some of the functionality of yargs being possible in yargs parser, maybe in the future the idea of commands.
Currently the only way to configure yargs-parser is by the following. (Excuse my mixed syntax)
I propose creating a builder pipeline that allows you to preconfigure your opts before running the command by adding an opts function to the Parser interface
This has a bunch of advantages:
Allows parser to check options ahead of time. This means that if after you create your parser with opts, yargs-parser doesn't have to do any of the setup of validation twice. So if you do
myParser("mystring")there is no need toany of the options pre-processing twice. The first time the args are even referenced on the parser function are like 150 lines of code in:
yargs-parser/lib/yargs-parser.ts
Line 203 in 5f987aa
Really good interop with ideas from Hopefully ending any and all discussion about how to handle quotes.... #300 if considered:
These are just a couple of thoughts. Other potential things that could come from this is some of the functionality of yargs being possible in yargs parser, maybe in the future the idea of commands.