mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Sascha Hauer <s.hauer@pengutronix.de>
To: Ahmad Fatoum <a.fatoum@pengutronix.de>
Cc: barebox@lists.infradead.org
Subject: Re: [PATCH] commands: add varinfo command
Date: Tue, 21 Jan 2025 08:27:09 +0100	[thread overview]
Message-ID: <Z49MTaSLjTvXEeMm@pengutronix.de> (raw)
In-Reply-To: <20250116140740.297902-1-a.fatoum@pengutronix.de>

Hi Ahmad,

On Thu, Jan 16, 2025 at 03:07:40PM +0100, Ahmad Fatoum wrote:
> +
> +	dev = get_device_by_name(arg);
> +	if (!dev)
> +		return -ENODEV;
> +
> +	list_for_each_entry(param, &dev->parameters, list) {
> +		if (prefix && !strstarts(param->name, prefix))
> +			continue;
> +
> +		printf("%s: %s (type: %s)", param->name,
> +		       dev_get_param(dev, param->name), get_param_type(param));
> +		if (param->info)
> +			param->info(param);
> +		printf("\n");
> +		found = true;
> +	}

This command is a bit inconsistent between handling of regular
environment variables and device parameters.

# foobar=baz; varinfo foo

prints "foo: no matching variable found" whereas a

# varinfo mmc0.c

prints all mmc0 device parameters starting with 'c'. Would be nice if
both variable types are handled equally in one way or the other.

> +
> +	if (!found)
> +		goto not_found;
> +
> +	return 0;
> +not_found:
> +	printf("%s: no matching variable found\n", arg);
> +	return 1;
> +}
> +
> +BAREBOX_CMD_HELP_START(varinfo)
> +BAREBOX_CMD_HELP_TEXT("shows information about the variable in its argument")
> +BAREBOX_CMD_HELP_END
> +
> +BAREBOX_CMD_START(varinfo)
> +	.cmd		= do_varinfo,
> +	BAREBOX_CMD_DESC("show information about variables")
> +	BAREBOX_CMD_OPTS("VAR")
> +	BAREBOX_CMD_GROUP(CMD_GRP_INFO)
> +	BAREBOX_CMD_HELP(cmd_varinfo_help)
> +	BAREBOX_CMD_COMPLETE(env_param_noeval_complete)

"varinfo foo<TAB>" expands to "varinfo foobar=". The equal sign
shouldn't be there.

Sascha

-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |



      reply	other threads:[~2025-01-21  7:32 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-01-16 14:07 Ahmad Fatoum
2025-01-21  7:27 ` Sascha Hauer [this message]

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=Z49MTaSLjTvXEeMm@pengutronix.de \
    --to=s.hauer@pengutronix.de \
    --cc=a.fatoum@pengutronix.de \
    --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