doggo/cmd/help.go

43 lines
996 B
Go
Raw Normal View History

2020-12-13 13:19:10 +01:00
package main
import (
2020-12-13 16:33:44 +01:00
"html/template"
"os"
2020-12-13 13:19:10 +01:00
)
2020-12-13 16:33:44 +01:00
// AppHelpTemplate is the text template to customise the Help output.
// Uses text/template to render templates.
var AppHelpTemplate = `NAME:
{{.Name}} {{.Description}}
USAGE:
{{.Name}} [OPTIONS] [--] <arguments>
2020-12-13 13:19:10 +01:00
2020-12-13 16:33:44 +01:00
VERSION:
{{.Version}} Built at {{.Date}}
EXAMPLES:
doggo mrkaran.dev Query a domain using defaults
doggo mrkaran.dev CNAME Looks up for a CNAME record.
doggo mrkaran.dev MX @9.9.9.9 Uses a custom DNS resolver.
doggo -q mrkaran.dev -t MX -n 1.1.1.1 Using named arguments
`
2020-12-13 13:19:10 +01:00
2020-12-13 16:33:44 +01:00
func renderCustomHelp() {
helpTmplVars := map[string]string{
"Name": "doggo",
"Description": "DNS Client for Humans",
"Version": buildVersion,
"Date": buildDate,
}
tmpl, err := template.New("test").Parse(AppHelpTemplate)
if err != nil {
panic(err)
}
err = tmpl.Execute(os.Stdout, helpTmplVars)
if err != nil {
panic(err)
}
os.Exit(0)
2020-12-13 13:19:10 +01:00
}