From mboxrd@z Thu Jan 1 00:00:00 1970 Return-path: Received: from mail-ee0-x22e.google.com ([2a00:1450:4013:c00::22e]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1Wkrag-00026Z-Ub for barebox@lists.infradead.org; Thu, 15 May 2014 09:04:39 +0000 Received: by mail-ee0-f46.google.com with SMTP id t10so416301eei.33 for ; Thu, 15 May 2014 02:04:16 -0700 (PDT) From: Holger Schurig Date: Thu, 15 May 2014 11:08:57 +0200 Message-Id: <1400144937-6006-3-git-send-email-holgerschurig@gmail.com> In-Reply-To: <1400144937-6006-1-git-send-email-holgerschurig@gmail.com> References: <1400144937-6006-1-git-send-email-holgerschurig@gmail.com> List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "barebox" Errors-To: barebox-bounces+u.kleine-koenig=pengutronix.de@lists.infradead.org Subject: [PATCH] magicvars: can now also list values To: barebox@lists.infradead.org Also uppercased the abbreviation GPIO in printf. Signed-off-by: Holger Schurig --- 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 #include +#include +#include #include 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