Skip to contentSkip to conversation

cmd: env: select: Add output for available evironment targets

PATCH Superseded Christoph Niedermaier 2 participants 3 messages Mar 20, 2025

v1 of 5 Superseded Latest is v5 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 cmd: env: select: Add output for available evironment targets

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.

Cc Marek Vasut <[email protected]>
Cc Patrick Delaunay <[email protected]>
Cc Joe Hershberger <[email protected]>
Cc Tom Rini <[email protected]>
---
 env/env.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)
env/env.c +12 -0
index bcc189e14db..999c2031c40 100644
@@ -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 */
Signature · 1 line
2.30.2
#1 lore raw
Quoted 2 lines · Christoph Niedermaier

If "env select" is called without a target parameter the result is "Select Environment on <NULL>: driver not found".

Why is this not the correct output ?

Quoted 3 lines

Improve the output
by showing a list of available evironment targets, where the active target is marked with an asterisk.

If the goal is to add support for listing available env options for 'env select' , then better modify cmd/nvedit.c do_env_select() and implement some 'env select -l' .

#2 lore raw

From: Marek Vasut <[email protected]>
Sent: Thursday, March 20, 2025 12:56 PM

Quoted 5 lines · Christoph Niedermaier
Quoted 2 lines

If "env select" is called without a target parameter the result is "Select Environment on <NULL>: driver not found".

Why is this not the correct output ?

I think it would be better to print an usage message here.

Quoted 7 lines
Quoted 3 lines

Improve the output
by showing a list of available evironment targets, where the active target is marked with an asterisk.

If the goal is to add support for listing available env options for 'env select' , then better modify cmd/nvedit.c do_env_select() and implement some 'env select -l' .

I could do this in v2.

Regards
Christoph