Files
openide/native/repair-utility/cmd/vmoptions.go
konstantin.annikov 01f61d2d78 [Repair Utility] move to community
GitOrigin-RevId: af0c92f448088c53578857b0e1b84b95c2664a4e
2022-11-09 16:13:29 +00:00

37 lines
1.1 KiB
Go

package cmd
import (
"github.com/spf13/cobra"
"repair/helpers"
"repair/logger"
)
var restoreVmoptionsFileBool bool
func init() {
rootCmd.AddCommand(vmoptionsCmd)
vmoptionsCmd.PersistentFlags().BoolVarP(&helpers.CheckVmoptionsFileBool, "check", "c", false, "Check .vmoptions file for correctness")
vmoptionsCmd.PersistentFlags().BoolVarP(&restoreVmoptionsFileBool, "restore", "r", false, "Reset .vmoptions file to default")
}
var vmoptionsCmd = &cobra.Command{
Use: "vmoptions",
Short: "Check for problems in .vmoptions file used to start the IDE",
Long: "Vmoptions aspect finds the .vmoptions file used by the IDE and analyzes its content. ",
SilenceUsage: true,
PreRun: func(cmd *cobra.Command, args []string) {
logger.InfoLogger.Println("VmOptions aspect started")
},
Run: func(cmd *cobra.Command, args []string) {
if restoreVmoptionsFileBool {
logger.ExitWithExceptionOnError(helpers.RestoreVmoptionsFile())
}
helpers.CheckVmoptionsFile()
},
PostRun: func(cmd *cobra.Command, args []string) {
logger.InfoLogger.Println("VmOptions aspect finished")
},
}