From 0bc6a097867724adfc70b96e62c32d0fca251147 Mon Sep 17 00:00:00 2001 From: Grail Finder Date: Thu, 9 Apr 2026 10:24:27 +0300 Subject: [PATCH] Enha: move flag parse into init --- bot.go | 8 ++++++++ main.go | 7 ------- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/bot.go b/bot.go index 84f1a44..92805a3 100644 --- a/bot.go +++ b/bot.go @@ -6,6 +6,7 @@ import ( "compress/gzip" "context" "encoding/json" + "flag" "fmt" "gf-lt/config" "gf-lt/models" @@ -1724,6 +1725,13 @@ func init() { // atomic default values cachedModelColor.Store("orange") go chatWatcher(ctx) + // parse flags + flag.BoolVar(&cfg.CLIMode, "cli", false, "Run in CLI mode without TUI") + flag.BoolVar(&cfg.ToolUse, "tools", true, "run with tools") + flag.StringVar(&cliCardPath, "card", "", "Path to syscard JSON file") + flag.BoolVar(&cliContinue, "continue", false, "Continue from last chat (by agent or card)") + flag.StringVar(&cliMsg, "msg", "", "Send message and exit (one-shot mode)") + flag.Parse() if !cfg.CLIMode { initTUI() } diff --git a/main.go b/main.go index 2a71920..6684c77 100644 --- a/main.go +++ b/main.go @@ -2,7 +2,6 @@ package main import ( "bufio" - "flag" "fmt" "gf-lt/models" "gf-lt/pngmeta" @@ -37,12 +36,6 @@ var ( ) func main() { - flag.BoolVar(&cfg.CLIMode, "cli", false, "Run in CLI mode without TUI") - flag.BoolVar(&cfg.ToolUse, "tools", true, "run with tools") - flag.StringVar(&cliCardPath, "card", "", "Path to syscard JSON file") - flag.BoolVar(&cliContinue, "continue", false, "Continue from last chat (by agent or card)") - flag.StringVar(&cliMsg, "msg", "", "Send message and exit (one-shot mode)") - flag.Parse() if cfg.CLIMode { runCLIMode() return