3 ms·
One could argue that -key value is much less simple than -X[=optional value]. Why would you ever need to "scale" a command to more than 30 options? At that poi
by peterwwillis 13y ago
One could argue that -key value is much less simple than -X[=optional value].
Why would you ever need to "scale" a command to more than 30 options? At that point you have a command line string that's 200 characters long, which is completely impractical for a command line. And in terms of distributed flags, who says one command wouldn't end up with the same flag name as another command?
Look at the gcc man page. It's ridiculous! They use a mix of longnames and short, and it's still confusing as hell. Why do they need this many options? Because for any given operation they want to be able to specify the overall options, language options, warning options, debugging options, optimization options, preprocessor options, assembler options, linker options, directory options, machine-dependent options, platform options, code gen options, etc. As if all of those options would relate to every single GCC operation!
They seem to have a mandate that input from ARGV is the only way to determine how to run their program. And it works for them; using autoconf and Makefiles you can configure the options each command will use in a very fine-grained way. But the end result is that for 99% of these cases, you have to use autoconf and Makefiles to make sense of anything! So what the hell is the point of stuffing them all in ARGV if a human isn't even going to use them anyway? They could have just as easily set environment variables and been done with it (lord knows why; probably some 30-year-old backwards compatibility issue)
I prefer the 'cvs' model of command-line processing. The creators knew they wanted one command which would let them do everything, but they also knew that there would be separate operations with their own options. So you specify a command, and then you specify your options. In this way, you know -a for 'ls' is probably going to be different than -a for 'diff' - but you can also look up these options incredibly easy using 'cvs --help command'. Now instead of having a soup of options to browse through, you know exactly what options relate to the specific operation you want to do.
The program's execution and options become easier to understand using this option hierarchy. It also distributes well because your commands have unique names. And no more looking up the 1000-page manual to find the one option you wanted.
- jzwinck 13y agoDid you know about GCC's --help=CLASS syntax, like --help=warnings ? I didn't either, but your post motivated me to look it up. That's a bit like what you'd want--help only for specific types of things--but it has some bizarre aspects, such as no apparent CLASS defined by operation [-c|-S|-E], so there is still no obvious way to know from the docs that the only option relevant with -E is -D (I think!). Another fun quirk is --help=undocumented, to "Display only those options which are undocumented."