in main.go [127:175]
func executeToolsNoDownloadAndExit(args []string) {
if len(args) < 2 {
banner()
os.Exit(0)
}
// if we have at least one arg
switch args[1] {
case "-v", "-version":
fmt.Println(OpsVersion)
os.Exit(0)
case "-h", "-help":
banner()
tools.Help(mainTools)
os.Exit(0)
case "-reset":
home := os.Getenv("OPS_HOME")
if home == "" {
log.Fatal("cannot determine the ops home dir")
os.Exit(1)
}
info, err := os.Stat(home)
if os.IsNotExist(err) {
fmt.Printf("%s does not exists - nothing to to do\n", home)
os.Exit(1)
}
if err != nil {
log.Fatal("error in reading the ops home dir", err.Error())
}
if !info.IsDir() {
log.Fatal("cannot reset, not a directory", home)
}
if len(args) == 2 || (len(args) > 2 && args[2] != "force") {
if !confirm(fmt.Sprintf("I am going to remove the subfolder %s (use force to skip this question).\nAre you sure [yes/no]:", home)) {
log.Fatal("reset aborted")
}
} else {
fmt.Println("removing without asking for confirmation as requested...")
}
err = os.RemoveAll(home)
if err != nil {
log.Fatal("ops reset error:", err.Error())
}
fmt.Println("ops -reset complete - execute ops -update to reload")
os.Exit(0)
default:
return
}
}