[Toybox] Thinking out loud (about command metadata simplification).
Rob Landley
rob at landley.net
Sun Feb 5 14:12:38 PST 2012
I can actually simplify the command metadata a bit more than I have.
It's one of those "be explicit" vs "less repetition" things...
The NEWTOY() and config lines can collapse together like this:
/* vi: set sw=4 ts=4:
*
* hello.c - A hello world program.
*
* Copyright 2012 Rob Landley <rob at landley.net>
*
* See http://opengroup.org/onlinepubs/9699919799/utilities/
COMMAND(hello, "e at d*c#b:a", TOYFLAG_USR|TOYFLAG_BIN)
default n
help
usage: [-a] [-b string] [-c number] [-d list] [-e count] [...]
A hello world program. You don't need this.
Mostly used as an example/skeleton file for adding new commands,
occasionally nice to test kernel booting via "init=/bin/hello".
*/
Note that the command name also drops out of the usage: line (because the
scripts/config2help.c file can put it back).
On the one hand, this is less repetition: when copying hello.c to a new
command name, you have to search/replace a lot less, and only have to do
it lower case. There's only two places left that functionally CARE, one
in the COMMAND() line and the other is hello_main().
On the other hand, it's less obvious at first glance that the blob after
the COMMAND() is kconfig language. (I could even suck the "default y/n"
and the "help" keyword up into the macro, but if you want to add DEPENDS
lines that gets awkward...)
/me shrugs. I'll hold off for now, but I'm always looking at ways to
improve on the existing stuff. Sort of the point of the project...
Trying to get a release out, but there's bugs to track down...
Rob
More information about the Toybox
mailing list