feat(v0.5.3): ResolveSessionMode env var resolver
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package config
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
@@ -148,6 +149,25 @@ func defaultSeedDir(leaf string) string {
|
||||
return filepath.Join(home, ".config", "ctask", leaf)
|
||||
}
|
||||
|
||||
// ResolveSessionMode returns "direct" or "persistent" based on CTASK_SESSION_MODE.
|
||||
// Default (unset/empty) is "direct". Any other value falls back to "direct"
|
||||
// after printing a stderr warning. Used by entry commands (new, resume, last,
|
||||
// open) to dispatch between the standard session.Run path and the tmux-backed
|
||||
// persistent path.
|
||||
func ResolveSessionMode() string {
|
||||
v := os.Getenv("CTASK_SESSION_MODE")
|
||||
switch v {
|
||||
case "", "direct":
|
||||
return "direct"
|
||||
case "persistent":
|
||||
return "persistent"
|
||||
default:
|
||||
fmt.Fprintf(os.Stderr,
|
||||
"[ctask] warning: CTASK_SESSION_MODE=%q is not recognized; using direct mode\n", v)
|
||||
return "direct"
|
||||
}
|
||||
}
|
||||
|
||||
// expandPath expands a leading ~/ and resolves to an absolute path when possible.
|
||||
func expandPath(p string) string {
|
||||
if strings.HasPrefix(p, "~/") || p == "~" {
|
||||
|
||||
Reference in New Issue
Block a user