attach default client to local daemon
This commit is contained in:
@@ -64,6 +64,7 @@ func main() {
|
||||
var (
|
||||
projectDir = flag.String("project", "", "project directory (default $PWD)")
|
||||
showVersion = flag.Bool("version", false, "print version and exit")
|
||||
inProcess = flag.Bool("in-process", false, "run the legacy single-process TUI instead of attaching to the daemon")
|
||||
debugDir = flag.String("debug", "", "write debug logs + per-child raw PTY output to DIR (auto-picks a dated subdir under $XDG_STATE_HOME/patterm/debug when DIR is omitted)")
|
||||
profileDir = flag.String("profile", "", "write pprof files (cpu/heap/goroutine) and live perf counters (metrics.jsonl per-second, metrics.json + summary.txt on exit) to DIR (auto-picks a dated subdir under $XDG_STATE_HOME/patterm/profile when DIR is omitted)")
|
||||
)
|
||||
@@ -84,6 +85,8 @@ func main() {
|
||||
}
|
||||
if *projectDir != "" {
|
||||
cwd = *projectDir
|
||||
} else if flag.NArg() > 0 {
|
||||
cwd = flag.Arg(0)
|
||||
}
|
||||
key, err := projectkey.Key(cwd)
|
||||
if err != nil {
|
||||
@@ -107,11 +110,26 @@ func main() {
|
||||
defer stopProfile()
|
||||
|
||||
ctx := context.Background()
|
||||
if err := app.Run(ctx, app.Options{
|
||||
if *inProcess || os.Getenv("PATTERM_NO_DAEMON") != "" {
|
||||
if err := app.Run(ctx, app.Options{
|
||||
ProjectDir: cwd,
|
||||
ProjectKey: key,
|
||||
DebugDir: resolvedDebug,
|
||||
ProfileDir: resolvedProfile,
|
||||
}); err != nil {
|
||||
die("%v", err)
|
||||
}
|
||||
return
|
||||
}
|
||||
if resolvedDebug != "" || resolvedProfile != "" {
|
||||
die("--debug and --profile currently require --in-process")
|
||||
}
|
||||
if err := app.RunAttachedClient(ctx, app.ClientOptions{
|
||||
ProjectDir: cwd,
|
||||
ProjectKey: key,
|
||||
DebugDir: resolvedDebug,
|
||||
ProfileDir: resolvedProfile,
|
||||
Stdin: os.Stdin,
|
||||
Stdout: os.Stdout,
|
||||
RawMode: true,
|
||||
AutoStart: true,
|
||||
}); err != nil {
|
||||
die("%v", err)
|
||||
}
|
||||
@@ -223,6 +241,8 @@ func runDaemonCommand() {
|
||||
}
|
||||
if *projectDir != "" {
|
||||
cwd = *projectDir
|
||||
} else if flag.NArg() > 0 {
|
||||
cwd = flag.Arg(0)
|
||||
}
|
||||
if err := app.RunDaemon(context.Background(), app.DaemonOptions{ProjectDir: cwd}); err != nil {
|
||||
die("daemon: %v", err)
|
||||
|
||||
Reference in New Issue
Block a user