support Maintainer field
parent
f685a9baa2
commit
c686492998
13
main.go
13
main.go
|
@ -75,20 +75,25 @@ func parseCommand(targetCmd *cobra.Command, yamlPath string) {
|
||||||
_, err := os.Stat(executablePath)
|
_, err := os.Stat(executablePath)
|
||||||
|
|
||||||
if err != nil {
|
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
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
yamlBytes, err := ioutil.ReadFile(yamlPath)
|
yamlBytes, err := ioutil.ReadFile(yamlPath)
|
||||||
if err != nil {
|
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
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
doc := commandDoc{}
|
doc := commandDoc{}
|
||||||
err = yaml.Unmarshal(yamlBytes, &doc)
|
err = yaml.Unmarshal(yamlBytes, &doc)
|
||||||
if err != nil {
|
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
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -104,6 +109,8 @@ func parseCommand(targetCmd *cobra.Command, yamlPath string) {
|
||||||
parsedCmd.Long = doc.LongDesc
|
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 != "" {
|
if doc.Examples != "" {
|
||||||
parsedCmd.Example = doc.Examples
|
parsedCmd.Example = doc.Examples
|
||||||
}
|
}
|
||||||
|
|
Reference in New Issue