From: Holger Schurig <holgerschurig@gmail.com>
To: barebox@lists.infradead.org
Subject: [PATCH] magicvars: can now also list values
Date: Thu, 15 May 2014 11:08:56 +0200 [thread overview]
Message-ID: <1400144937-6006-2-git-send-email-holgerschurig@gmail.com> (raw)
In-Reply-To: <1400144937-6006-1-git-send-email-holgerschurig@gmail.com>
Also uppercased the abbreviation GPIO in printf.
Signed-off-by: Holger Schurig <holgerschurig@gmail.com>
---
commands/magicvar.c | 30 +++++++++++++++++++++++++++++-
1 file changed, 29 insertions(+), 1 deletion(-)
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
--
1.7.10.4
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
next prev parent reply other threads:[~2014-05-15 9:04 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-05-15 9:08 [PATCH] commands: rename "gpiolib" -> "gpioinfo" Holger Schurig
2014-05-15 9:08 ` Holger Schurig [this message]
2014-05-15 9:08 ` [PATCH] magicvars: can now also list values Holger Schurig
2014-05-15 9:20 ` [PATCH] commands: rename "gpiolib" -> "gpioinfo" Sebastian Hesselbarth
2014-05-15 9:49 ` Holger Schurig
2014-05-15 12:40 ` Sascha Hauer
2014-05-15 12:52 ` Sebastian Hesselbarth
2014-05-15 13:01 ` Sascha Hauer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1400144937-6006-2-git-send-email-holgerschurig@gmail.com \
--to=holgerschurig@gmail.com \
--cc=barebox@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox