do I know anyone that's going to brighton ruby this week?
he/him : you may know me as @mountain_ghosts on twitter : I wrote some books you can buy from https://shop.jcoglan.com
do I know anyone that's going to brighton ruby this week?
@glenjamin as I detailed elsewhere, yargs is the most broken of any of the things I've tried, unfortunately
@mcc this is the most tempting thing for me to put effort into at least, just because its parsing approach doesn't seem fundamentally broken
@mcc the issue is that if you declare an argument, it seems to become required, which would mean I'd need to change my program's interface. might be possible, I'm not sure, but it's also a symptom of this library assuming you want to use it to define a bunch of subcommands
the joint effects of semver and the node.js release process making people think they don't need to support old software, when node.js itself is remarkably stable and runs stuff I wrote 10+ years ago, continues to drive me mad
my options right now:
- live with the deprecation warning on posix-argv-parser which actually works
- use utils.parseArgs() and drop support for node versions released as little as 2 years ago
- write my own parser
these are all, bad
@clementd I don't even need "commands". I need an option parser but nobody makes on of those
support for positional args was regarded as "opinionated" and dismissed out of hand https://github.com/tj/commander.js/issues/193
@clementd yeah these APIs are incredibly annoying to migrate my application between to try them all out, so much so I often end up writing a transformer from the nopt API
(commander parses switches properly, but is a mess on positional arguments, and steps out of scope by calling process.exit() which is not its job)
a parsing library should not exit the process of its own volition, what on earth are you doing
node.js when you're making a web app: you don't need a framework, glue these libraries together
node.js when you want to parse a command-line: it looks like you want an application framework
@mcc it also crashes your process on errors b/c it wants to be an "application framework" instead of a parsing library
@mcc this certainly looks more promising in terms of parsing switches with values correctly, but I can't figure out how to get positional args out of it. do you know how?
like this is fundamentally not how you approach parsing. I'd expect *some* libraries to make this design error, but all of them? literally every single popular one?
I am absolutely baffled that every single option parsing library in node.js makes the same fundamental design mistake of guessing the options from user input
the security warning on minimist is like, yeah, that'll happen if you let the options be defined by user input instead of by the program, so why does every library do the former https://www.npmjs.com/package/minimist
yargs is just incompatible with software engineering since it effectively makes it impossible to unit test your program
parseArgs() is the least actively broken one in that it can be made to understand when a value looks like a switch, except it forces the user to use '=' to express this, its output is the cleanest and it doesn't make any guesses
I think my best option is to use util.parseArgs(), and accept this forces me to drop some older node versions, which actively sucks considering I had put prior effort in elsewhere to keep them working? seems like a bad trade off