support Maintainer field

master
vilmibm 2020-06-09 04:36:29 +00:00
parent f685a9baa2
commit c686492998
1 changed files with 10 additions and 3 deletions

13
main.go
View File

@ -75,20 +75,25 @@ func parseCommand(targetCmd *cobra.Command, yamlPath string) {
_, err := os.Stat(executablePath)
if err != nil {
fmt.Fprintf(os.Stderr, "could not find matching executable for %s; skipping...", yamlPath)
fmt.Fprintf(os.Stderr, "could not find matching executable for %s; skipping...\n", yamlPath)
return
}
yamlBytes, err := ioutil.ReadFile(yamlPath)
if err != nil {
fmt.Fprintf(os.Stderr, "could not read %s; skipping...", yamlPath)
fmt.Fprintf(os.Stderr, "could not read %s; skipping...\n", yamlPath)
return
}
doc := commandDoc{}
err = yaml.Unmarshal(yamlBytes, &doc)
if err != nil {
fmt.Fprintf(os.Stderr, "could not parse %s; skipping...", yamlPath)
fmt.Fprintf(os.Stderr, "could not parse %s; skipping...\n", yamlPath)
return
}
if doc.Maintainer == "" {
fmt.Fprintf(os.Stderr, "%s is missing maintainer field; skipping...\n", yamlPath)
return
}
@ -104,6 +109,8 @@ func parseCommand(targetCmd *cobra.Command, yamlPath string) {
parsedCmd.Long = doc.LongDesc
}
parsedCmd.Long += fmt.Sprintf("\nMaintained by %s; reach out to them via mail or chat with questions", doc.Maintainer)
if doc.Examples != "" {
parsedCmd.Example = doc.Examples
}