mirror of
https://github.com/floci-io/floci-cli.git
synced 2026-11-23 14:10:50 -05:00
fix(env): show how to load the variables in the chosen shell and reject unknown shells (#46)
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:
1 parent
030d468fd3
commit
fbdc3ef713
7 files changed
+119
-15
No files matched your search
@@ -36,14 +36,18 @@ public class GcpEnvCommand implements Callable<Integer> {
|
||||
String serviceFilter;
|
||||
|
||||
@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());
|
||||
String host = extractHost(effectiveEndpoint);
|
||||
int port = extractPort(effectiveEndpoint);
|
||||
@@ -67,7 +71,7 @@ public class GcpEnvCommand implements Callable<Integer> {
|
||||
printer.println(ShellExport.formatExport(shell, entry.getKey(), entry.getValue()));
|
||||
}
|
||||
printer.println("");
|
||||
printer.println(Ansi.gray("# Run: eval $(floci gcp env)"));
|
||||
printer.println(Ansi.gray("# Run: " + ShellExport.loadHint(shell, "floci gcp env")));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user