From 70320156e47e14a8942730ec4311b728966e41df Mon Sep 17 00:00:00 2001 From: wuko233 Date: Sun, 19 Apr 2026 20:03:22 +0800 Subject: [PATCH] =?UTF-8?q?[cmd]=20=E4=BF=AE=E5=A4=8Dstatus=E4=B8=8Esafe?= =?UTF-8?q?=E5=91=BD=E4=BB=A4=E9=85=8D=E7=BD=AE=E6=96=87=E4=BB=B6=E8=AF=BB?= =?UTF-8?q?=E5=8F=96=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cmd/safe/safe.go | 6 +++--- cmd/status/status.go | 7 +++---- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/cmd/safe/safe.go b/cmd/safe/safe.go index 50cd530..6326af5 100644 --- a/cmd/safe/safe.go +++ b/cmd/safe/safe.go @@ -21,9 +21,9 @@ func NewSafeCmd() *cobra.Command { Short: "交互式安全确认,将可疑对象加入白名单", Long: "查看当前的可疑文件和进程列表,并选择将其移入白名单。", Run: func(cmd *cobra.Command, args []string) { - cfg, err := config.LoadConfig("./config.yaml") - if err != nil { - fmt.Printf("加载配置失败: %v\n", err) + cfg, ok := cmd.Context().Value("config").(*config.Config) + if !ok { + fmt.Println("无法获取配置") os.Exit(1) } diff --git a/cmd/status/status.go b/cmd/status/status.go index d5507b2..c046e2a 100644 --- a/cmd/status/status.go +++ b/cmd/status/status.go @@ -16,10 +16,9 @@ func NewStatusCmd() *cobra.Command { Short: "显示系统状态", Long: "显示Sysmonitod的当前状态", Run: func(cmd *cobra.Command, args []string) { - cfg, err := config.LoadConfig("./config.yaml") - - if err != nil { - fmt.Printf("加载配置失败: %v\n", err) + cfg, ok := cmd.Context().Value("config").(*config.Config) + if !ok { + fmt.Println("无法获取配置") os.Exit(1) }