mirror of
https://github.com/floci-io/floci-cli.git
synced 2026-11-22 21:50:47 -05:00
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:
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()) {
|
||||
|
||||
Reference in new issue
Block a user