fix(cli): make env load hints loadable with a JSON profile and in every shell

A profile can set output: json, so the hint now adds -o text after --profile; pasted without it, the shell received JSON. Selector values are quoted for the shell the hint is for, since PowerShell and fish do not read the POSIX form. Addresses the review of #74.

Signed-off-by: Hector Ventura <hectorvent@gmail.com>
This commit is contained in:
Hector Ventura committed 2026-11-04 00:38:42 -06:00
1 parent b0d4a4eb31
commit a65bc95e41
7 files changed
+62 -10

No files matched your search

@@ -39,6 +39,15 @@ public final class ShellExport {
};
}
/** {@code value} as one single-quoted argument in the given shell. */
public static String quoted(String shell, String value) {
return switch (shell.toLowerCase()) {
case "fish" -> "'" + value.replace("\\", "\\\\").replace("'", "\\'") + "'";
case "powershell", "pwsh", "ps1" -> "'" + value.replace("'", "''") + "'";
default -> "'" + value.replace("'", "'\\''") + "'";
};
}
/** Renders one export line for the given shell ({@code bash}, {@code fish}, {@code powershell}). */
public static String formatExport(String shell, String key, String value) {
return switch (shell.toLowerCase()) {