News for hackers. Stuff that matters.
Re:Embedded malware in RC (NPM package) by afavour on Friday November 05, 2021 @02:24PM (#29122977)
Command line argument parsing and config loading both seem like very sensible library abstractions to me. This isn’t leftpad.
Re:Embedded malware in RC (NPM package) by havkd on Friday November 05, 2021 @02:40PM (#29123180)
Command line argument parsing and config loading both seem like something that the standard library should provide.
Re:Embedded malware in RC (NPM package) by megumax on Friday November 05, 2021 @02:59PM (#29123397)
Ok, now, what languages beside Python and Go provide Command line argument parsing? And Go doesn't do that in a `professional` way. You either write your own, which can easily turn into a clusterfuck or use a third party library. Even in Go, people use cobra[1]. Also embedding a lot of functionality in a standard library isn't great as well, because if some vulnerability is found, it's really hard to patch it, because you need to push versions and (for example on Linux) some distro maintainers won't push it for `stability` etc. A standard library should provide basic functionality (in most general areas), but not very advanced one.

[1] https://github.com/spf13/cobra

Re:Embedded malware in RC (NPM package) by morelisp on Friday November 05, 2021 @03:18PM (#29123635)
> what languages beside Python and Go provide Command line argument parsing?

Even POSIX gives you getopt(1) and getopt(3). What other language doesn't? I can only think of Java.

Re:Embedded malware in RC (NPM package) by megumax on Friday November 05, 2021 @03:29PM (#29123747)
POSIX is not ISO C or C++ standard. On Windows, what are you gonna do?

Also, other languages are Rust, Kotlin, Swift (to name a few `modern` ones). Yes, Kotlin and Swift have `first class` CLI parsing libraries, but they are not part of standard library.

Re:Embedded malware in RC (NPM package) by morelisp on Friday November 05, 2021 @04:46PM (#29124567)
"First-party" is distinct from "first class". The difference between a first-party library and the standard library ranges from "slightly weaker compatibility guarantees" to "it's supported in all environments where it makes sense, but the language can run unhosted so that's not everywhere" to "no difference at all, we just didn't want to package it with the compiler".

You're also missing the forest for the "well actually" trees: Lots of languages have argument parsing in their stdlib.

Re:Embedded malware in RC (NPM package) by afavour on Friday November 05, 2021 @04:09PM (#29124189)
Sure, and Node gives you the process.argv array. The point is having higher level APIs than that.
Re:Embedded malware in RC (NPM package) by voldacar on Friday November 05, 2021 @06:02PM (#29125175)
it feels like the more higher level APIs we add, the shittier and more annoying software becomes
Re:Embedded malware in RC (NPM package) by morelisp on Friday November 05, 2021 @04:40PM (#29124500)
getopt is a higher-level API. process.argv is equivalent to, uh, argv.
Re:Embedded malware in RC (NPM package) by kitsunesoba on Friday November 05, 2021 @03:14PM (#29123585)
It's not part of the standard library, but Swift has the first-party ArgumentParser[0]. Other languages could use a similar model (though what "first party" means for JavaScript is unclear).

[0]: https://github.com/apple/swift-argument-parser

Re:Embedded malware in RC (NPM package) by Groxx on Friday November 05, 2021 @06:18PM (#29125308)
as if there even was one command-line or config standard. especially across different operating systems.

it absolutely does not belong in stdlibs, where it can never be changed. that's how you end up with too many terrible CLI tools using Go's `flags` package.

Re:Embedded malware in RC (NPM package) by chakkepolja on Saturday November 06, 2021 @12:43AM (#29127593)
I don't understand, what's wrong with Go's flag, compared to, say, python's argparse?
Re:Embedded malware in RC (NPM package) by MrStonedOne on Friday November 05, 2021 @05:48PM (#29125071)
php
Re:Embedded malware in RC (NPM package) by qwerty2021 on Friday November 05, 2021 @02:48PM (#29123281)
>Command line argument parsing

20-30 LoC maybe. `process.argv.slice(2).forEach(str => ... )`.

there is no access to the raw command-line invocation, sadly, so you really can't really do anything fancier than that.

>config loading

that thing "RC" package does - looking up the config file in random locations - is really strange to me. aren't you the one in control of where it is stored?

Re:Embedded malware in RC (NPM package) by afavour on Friday November 05, 2021 @04:34PM (#29124437)
Just looking at the readme for Coa it’s very obviously more than the code you outlined. You’re arguing against a strawman here.
Re:Embedded malware in RC (NPM package) by qwerty2021 on Friday November 05, 2021 @05:16PM (#29124832)
honestly, yeah. I just saw "command line parser" and dismissed the rest as useless bloat