77// existing default-named file (so a bare `--report` is non-destructive),
78// then collects data and renders the HTML output.
79▶func runReport(paths []string) error {
80 path := "."
81 if len(paths) > 0 {
· · ·
108// The io.Reader / io.Writer seam keeps the function unit-testable without
109// poking at os.Stdin / os.Stderr.
110▶func confirmReportOverwrite(outPath string, usedDefaultName, stdinIsTTY bool, in io.Reader, out io.Writer) error {
111 if !usedDefaultName {
112 return nil
· · ·
115 return nil
116 } else if err != nil {
117▶ // Some other stat error (permission?) — let the subsequent
118 // os.Create surface the underlying problem with a clearer
119 // "create report file: ..." wrapper instead of a stat error
· · ·
119▶ // "create report file: ..." wrapper instead of a stat error
120 // nobody asked for.
121 return nil
· · ·
122 }
123 if !stdinIsTTY {
124▶ return fmt.Errorf("%s already exists; rerun with --report=%s to overwrite explicitly", outPath, outPath)
125 }
126 _, _ = fmt.Fprintf(out, "%s already exists. Overwrite? [y/N]: ", outPath)
+ 7 more matches in this file