Export command line flags as environment variables (#2079)

This commit is contained in:
Joe Lim authored and GitHub committed 2025-08-07 15:59:13 +10:00
1 parent 42b36fd52c
commit 02156a3806
4 files changed
+25 -1

No files matched your search

+11
View File
@@ -89,6 +89,16 @@ func exportEnvVars() {
os.Setenv("LF_LEVEL", strconv.Itoa(level))
}
func exportFlags() {
os.Setenv("lf_flag_config", gConfigPath)
os.Setenv("lf_flag_last_dir_path", gLastDirPath)
os.Setenv("lf_flag_log", gLogPath)
os.Setenv("lf_flag_print_last_dir", strconv.FormatBool(gPrintLastDir))
os.Setenv("lf_flag_print_selection", strconv.FormatBool(gPrintSelection))
os.Setenv("lf_flag_selection_path", gSelectionPath)
os.Setenv("lf_flag_single", strconv.FormatBool(gSingleMode))
}
// used by exportOpts below
func fieldToString(field reflect.Value) string {
kind := field.Kind()
@@ -355,6 +365,7 @@ func main() {
}
exportEnvVars()
exportFlags()
run()
}