Closed curiousdannii closed 1 year ago
How would that be different than process.argv
?
The options may not have originated in process.argv
. Or in my case, I'm thinking of a script that parses its process.argv
options, modifies or removes some of them, and then calls another program with the result.
Completely fine if it's out of scope, but as I'm already using minimist I thought it would be worth asking. (And no one had previously asked, though I now see that's because all the old issues were lost when the old repo was deleted.)
Certainly minimist could hold on to the original arg string it's given, and provide it back out somehow - but I think serializing a parsed object into an argument string is a very complex task, and would need to be able to understand all of minimist's options.
Are there any other argument parsing tools that provide this functionality?
Sure thing.
I haven't looked into any alternatives yet. There are a lot of other arg parsers on npm so probably one of them would support it. Thanks!
Oh, I didn't mean "go use those" :-) i meant, is there any prior art to look at.
Please feel free to reopen after you've looked into it!
I am aware of a couple of implementations, the first of which looks like just what you are asking for:
If it's relatively lightweight to bring in dargs' functionality to minimist - especially since dargs is ESM-only now, and thus unusable - that's worth considering.
A link in the readme would probably be enough.
I don't think it'd be a good idea to endorse any package that has moved to ESM-only, even tacitly with a link.
Hah, I'm on-board with ESM, but I wouldn't want to argue it. Do whatever you feel is best! :)
Any package that can be (synchronously) consumed by both of node's module systems is great! That includes CJS-only, and dual packages. It's only ESM-only packages that are harmful by excluding the majority of the ecosystem.
It might be out of scope, but it would be helpful to have a function that would turn minimist's parsed options back into an argv array.