fix(env): show how to load the variables in the chosen shell and reject unknown shells

The closing hint of floci env (all four products) now uses source for fish and Invoke-Expression for PowerShell instead of always suggesting eval, and an unknown --shell exits 2 with the accepted values instead of silently printing bash syntax. zsh, sh and pwsh are accepted by name.
This commit is contained in:
Hector Ventura committed 2026-10-09 17:16:47 -05:00
1 parent 0746e1a61c
commit 5300e83b24
7 files changed
+119 -15

No files matched your search

@@ -36,14 +36,18 @@ public class EnvCommand implements Callable<Integer> {
String region;
@Option(names = {"--shell"},
description = "Shell format: bash, fish, powershell (default: bash)",
description = "Shell format: bash, zsh, sh, fish, powershell (default: bash)",
defaultValue = "bash",
paramLabel = "bash|fish|powershell")
paramLabel = "<shell>")
String shell;
@Override
public Integer call() {
Printer printer = global.printer();
if (!ShellExport.isSupported(shell)) {
printer.error(ShellExport.unsupported(shell));
return 2;
}
String effectiveEndpoint = global.resolvedEndpoint(new DockerClient());
int port = extractPort(effectiveEndpoint);
String endpointUrl = "http://" + host + ":" + port;
@@ -63,7 +67,7 @@ public class EnvCommand implements Callable<Integer> {
printer.println(ShellExport.formatExport(shell, entry.getKey(), entry.getValue()));
}
printer.println("");
printer.println(Ansi.gray("# Run: eval $(floci env)"));
printer.println(Ansi.gray("# Run: " + ShellExport.loadHint(shell, "floci env")));
return 0;
}