summaryrefslogtreecommitdiffstats
path: root/commands/magicvar.c
diff options
context:
space:
mode:
authorHolger Schurig <holgerschurig@gmail.com>2014-05-15 11:08:56 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2014-05-15 14:44:33 +0200
commit0b6d24c0d7659f9a051990f694faa1031055cb1a (patch)
tree6633c1e23d806907fe9d79c70fa1942488de7664 /commands/magicvar.c
parent2071940c76e872a67f9a4de6ba6d47bb570c876c (diff)
downloadbarebox-0b6d24c0d7659f9a051990f694faa1031055cb1a.tar.gz
magicvars: can now also list values
Also uppercased the abbreviation GPIO in printf. Signed-off-by: Holger Schurig <holgerschurig@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'commands/magicvar.c')
-rw-r--r--commands/magicvar.c30
1 files changed, 29 insertions, 1 deletions
diff --git a/commands/magicvar.c b/commands/magicvar.c
index d92788a..cf1fe45 100644
--- a/commands/magicvar.c
+++ b/commands/magicvar.c
@@ -1,21 +1,49 @@
#include <common.h>
#include <command.h>
+#include <getopt.h>
+#include <environment.h>
#include <magicvar.h>
static int do_magicvar(int argc, char *argv[])
{
struct magicvar *m;
+ int opt;
+ int verbose = 0;
+
+ while ((opt = getopt(argc, argv, "v")) > 0) {
+ switch (opt) {
+ case 'v':
+ verbose = 1;
+ break;
+ default:
+ return COMMAND_ERROR_USAGE;
+ }
+ }
for (m = &__barebox_magicvar_start;
m != &__barebox_magicvar_end;
- m++)
+ m++) {
printf("%-32s %s\n", m->name, m->description);
+ if (verbose) {
+ const char *val = getenv(m->name);
+ if (val && strlen(val))
+ printf(" %s\n", val);
+ }
+ }
return 0;
}
+
+BAREBOX_CMD_HELP_START(magicvar)
+BAREBOX_CMD_HELP_TEXT("Options:")
+BAREBOX_CMD_HELP_OPT ("-v", "verbose (list all value if there is one)")
+BAREBOX_CMD_HELP_END
+
BAREBOX_CMD_START(magicvar)
.cmd = do_magicvar,
BAREBOX_CMD_DESC("list information about magic variables")
+ BAREBOX_CMD_OPTS("[-v]")
+ BAREBOX_CMD_HELP(cmd_magicvar_help)
BAREBOX_CMD_GROUP(CMD_GRP_ENV)
BAREBOX_CMD_END