[PATCH] commands: add varinfo command
Sascha Hauer
s.hauer at pengutronix.de
Mon Jan 20 23:27:09 PST 2025
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 |
More information about the barebox
mailing list