[cmd] 修复status与safe命令配置文件读取问题

This commit is contained in:
wuko233 2026-04-19 20:03:22 +08:00
parent fcdbc4ed41
commit 70320156e4
2 changed files with 6 additions and 7 deletions

View File

@ -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)
}

View File

@ -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)
}