docs/man/mangen.go: move fmt.Fprintf to warnf, too
For fatal error messages, let's move calls to fmt.Fprintf to a 'warnf' function so that the call-sites appear similar to that of 'infof'.
This commit is contained in:
parent
3c17098d02
commit
483098e7bf
@ -15,6 +15,10 @@ func infof(w io.Writer, format string, a ...interface{}) {
|
||||
fmt.Fprintf(w, format, a...)
|
||||
}
|
||||
|
||||
func warnf(w io.Writer, format string, a ...interface{}) {
|
||||
fmt.Fprintf(w, format, a...)
|
||||
}
|
||||
|
||||
func readManDir() (string, []os.FileInfo) {
|
||||
rootDirs := []string{
|
||||
"..",
|
||||
@ -29,7 +33,7 @@ func readManDir() (string, []os.FileInfo) {
|
||||
}
|
||||
}
|
||||
|
||||
fmt.Fprintf(os.Stderr, "Failed to open man dir: %v\n", err)
|
||||
warnf(os.Stderr, "Failed to open man dir: %v\n", err)
|
||||
os.Exit(2)
|
||||
return "", nil
|
||||
}
|
||||
@ -45,7 +49,7 @@ func main() {
|
||||
manDir := filepath.Join(rootDir, "docs", "man")
|
||||
out, err := os.Create(filepath.Join(rootDir, "commands", "mancontent_gen.go"))
|
||||
if err != nil {
|
||||
fmt.Fprintf(os.Stderr, "Failed to create go file: %v\n", err)
|
||||
warnf(os.Stderr, "Failed to create go file: %v\n", err)
|
||||
os.Exit(2)
|
||||
}
|
||||
out.WriteString("package commands\n\nfunc init() {\n")
|
||||
@ -69,7 +73,7 @@ func main() {
|
||||
out.WriteString("ManPages[\"" + cmd + "\"] = `")
|
||||
contentf, err := os.Open(filepath.Join(manDir, f.Name()))
|
||||
if err != nil {
|
||||
fmt.Fprintf(os.Stderr, "Failed to open %v: %v\n", f.Name(), err)
|
||||
warnf(os.Stderr, "Failed to open %v: %v\n", f.Name(), err)
|
||||
os.Exit(2)
|
||||
}
|
||||
// Process the ronn to make it nicer as help text
|
||||
|
Loading…
Reference in New Issue
Block a user