Added printHelp, provide more info on -h and -v

This commit is contained in:
asdf 2019-10-22 14:45:39 +11:00
parent d5246a7d3e
commit 95837e108a
1 changed files with 20 additions and 3 deletions

23
main.go
View File

@ -112,7 +112,7 @@ func loadConfig() error {
if lowerkey == "configlocation" {
// The config defaults to the home folder.
// Users cannot really edit this value. But
// a compile time override is available.
// a compile time override is available.
// It is still stored in the ini and as a part
// of the options map.
continue
@ -161,11 +161,28 @@ func handleSIGCONT(c <-chan os.Signal) {
}
}
//printHelp produces a nice display message when the --help flag is used
func printHelp() {
art := `Bombadillo
Syntax: bombadillo [url]
bombadillo [options...]
Example: bombadillo gopher://bombadillo.colorfield.space
bombadillo -v
Options:
`
fmt.Fprint(os.Stdout, art)
flag.PrintDefaults()
}
func main() {
getVersion := flag.Bool("v", false, "See version number")
getVersion := flag.Bool("v", false, "Print version information and exit")
flag.Usage = printHelp
flag.Parse()
if *getVersion {
fmt.Printf("Bombadillo %s\n", version)
fmt.Printf("Bombadillo %s - build %s\n", version, build)
os.Exit(0)
}
args := flag.Args()