Remaining work for yargs v17 release
See original GitHub issuev17 is a large release, in which I’ve tried to address many long outstanding oddities related to middleware, async handlers, check functions, coerce functions, help output from commands.
There are still a few more tasks I would like to complete before we push it out the door:
- Node 10 is about to EOL, so I’d like to drop Node 10 before we take on the next major.
- skim through any recent
docs
issues and update docs pertinent to this release. - land @OsmanAltun’s work on https://github.com/yargs/yargs/pull/1882
- ~figure out why WebPack has issues with our current export maps.~ The problem with bundlephobia is
import.meta
, which cannot be removed Refs: https://github.com/yargs/yargs/pull/1900 - ~try to reduce unpacked module size under 300kb (this is becoming increasingly difficult, since much of the size is due to lines of code).~ using terser to minify the common-js bundle works great, Refs: https://github.com/yargs/yargs/pull/1901
- make sure that https://github.com/DefinitelyTyped/DefinitelyTyped/pull/52169 is ready to merge, so that we don’t break TypeScript users for any length of time. (@seivan is pitching in on this work).
- update TypeScript docs. (@seivan is pitching in on this work).
If you would like to help QA, npm i yargs@next
.
Issue Analytics
- State:
- Created 2 years ago
- Comments:12 (12 by maintainers)
Top Results From Across the Web
Releases · yargs/yargs - GitHub
completion: choices will now work for all possible aliases of an option and not just the default long option (30edd50) ...
Read more >docs/api.md | yargs@v17.4.1-deno
When passing in the arguments yourself, note that Yargs expects the passed array to contain only the arguments after the program name, while...
Read more >yargs show main help after parse - Stack Overflow
I have the following code const yargs = require("yargs"); const parser = yargs.command("test", "description", (yargs) ...
Read more >demo/node_modules/yargs - GitLab
Yargs be a node.js library fer hearties tryin' ter parse optstrings. ... Build Status Coverage Status NPM version Windows Tests js-standard-style ...
Read more >concurrently - node_modules - yargs - CHANGELOG.md
middleware should work regardless of when method is called (664b265), ... upgrade to version of yargs-parser that does not populate value for unset...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@bcoe I am just fixing things as I go along https://github.com/DefinitelyTyped/DefinitelyTyped/pull/52265
Honestly the types should be in here and generated by in the repo since this is a Typescript project after all, but more importantly should be true to the source code more than anything. Maintaining types externally seems like an accident waiting to happen.
More so, it’s painful to see so much potential for better types and API.
For instance a command should’t take more than a single middleware instead of an array and its return type would be combined with the types defined in
builder
before being passed to ahandler
That way abuilder
defines input’s that are expected and a middleware can then process those before moving to ahandler
An example would be that a command that expects
--path: string
to some file and a middleware would use that to read the content of said file and return the updated arg.The
handler
would then get{path: string, fileContent: string | undefined}
.@bcoe That sounds like a great idea, though I’d argue in order to keep things succinct, maybe omit certain approaches that aren’t taking advantage of the type system .
I did some tests of my own and cross-posting here:
While it does not work (out of the box) with
CommandModule
However there is partial support for just options and not positional. But you can’t have a builder and you lose descriptions, it literally skips over them when printing usage.
To get typed arguments and avoid polluting the argument interface from other sub-commands in the same parent you need to wrap the entire sub-command in a function. To rephrase: sub-command siblings will get access to each other arguments and positional if they are not wrapped in a function.