package installcmd import ( "os" "github.com/spf13/cobra" "yizhisec.com/hsv2/forge/internal/controller/installer" ) func Check() *cobra.Command { var ( workdir string target string ignoreDisk bool ignoreMemory bool ignoreCPU bool ) _cmd := &cobra.Command{ Use: "check", Short: "Check system requirements", Long: `Check system requirements for the project.`, PreRun: func(cmd *cobra.Command, args []string) { if os.Getenv("FORGE_NO_CHECK_DISK") == "true" { ignoreDisk = true } if os.Getenv("FORGE_NO_CHECK_MEMORY") == "true" { ignoreMemory = true } if os.Getenv("FORGE_NO_CHECK_CPU") == "true" { ignoreCPU = true } }, RunE: func(cmd *cobra.Command, args []string) error { _installer := installer.NewInstaller(workdir, target) return _installer.Check( cmd.Context(), installer.WithIgnoreDiskCheck(ignoreDisk), installer.WithIgnoreMemoryCheck(ignoreMemory), installer.WithIgnoreCPUCheck(ignoreCPU), ) }, } _cmd.Flags().StringVar(&workdir, "workdir", "/root/hs-installation", "Working directory") _cmd.Flags().StringVar(&target, "target", "self", "Target") return _cmd }