(file string)
| 84 | } |
| 85 | |
| 86 | func askDeleteFile(file string) { |
| 87 | if fileinfo, err := os.Stat(file); err == nil { |
| 88 | if fileinfo.IsDir() { |
| 89 | return |
| 90 | } |
| 91 | reader := bufio.NewReader(os.Stdin) |
| 92 | fmt.Printf("\"%s\" already exists. \nDo you want to delete it? (y or n, press Enter for default n):\n", |
| 93 | file) |
| 94 | t, err := reader.ReadString('\n') |
| 95 | t = strings.Trim(t, "\n") |
| 96 | if err != nil { |
| 97 | ConsoleLog.WithError(err).Error("unexpected error") |
| 98 | SetExitStatus(1) |
| 99 | Exit() |
| 100 | } |
| 101 | if strings.EqualFold(t, "y") || strings.EqualFold(t, "yes") { |
| 102 | err = os.Remove(file) |
| 103 | if err != nil { |
| 104 | ConsoleLog.WithError(err).Error("unexpected error") |
| 105 | SetExitStatus(1) |
| 106 | Exit() |
| 107 | } |
| 108 | } else { |
| 109 | Exit() |
| 110 | } |
| 111 | } |
| 112 | } |
| 113 | |
| 114 | func runGenerate(cmd *Command, args []string) { |
| 115 | commonFlagsInit(cmd) |
no test coverage detected