If "env select" is called without a target parameter the result is
"Select Environment on <NULL>: driver not found". Improve the output
by showing a list of available evironment targets, where the active
target is marked with an asterisk.

Signed-off-by: Christoph Niedermaier <cniederma...@dh-electronics.com>

Cc: Marek Vasut <ma...@denx.de>
Cc: Patrick Delaunay <patrick.delau...@foss.st.com>
Cc: Joe Hershberger <joe.hershber...@ni.com>
Cc: Tom Rini <tr...@konsulko.com>
---
 env/env.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/env/env.c b/env/env.c
index bcc189e14db..999c2031c40 100644
--- a/env/env.c
+++ b/env/env.c
@@ -355,6 +355,18 @@ int env_select(const char *name)
        int prio;
        bool found = false;
 
+       if (!name) {
+               printf("Available Environment targets:\n");
+               for (prio = 0; (drv = env_driver_lookup(ENVOP_INIT, prio)); 
prio++) {
+                       if (gd->env_load_prio == prio)
+                               printf("* ");
+                       else
+                               printf("  ");
+                       printf("%s\n", drv->name);
+               }
+               return 0;
+       }
+
        printf("Select Environment on %s: ", name);
 
        /* search ENV driver by name */
-- 
2.30.2

Reply via email to