Skip to content

Commit a094062

Browse files
Merge pull request #2 from cooperqmarshall/help-argument-fix
Add custom `-h` and `--help` flag output
2 parents ad1ff6e + 36004e7 commit a094062

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

gozer.go

+4-1
Original file line numberDiff line numberDiff line change
@@ -376,16 +376,19 @@ func parseConfig(s *Site, file string) error {
376376
func main() {
377377
configFile := "config.toml"
378378
rootPath := ""
379+
showHelp := false
379380

380381
// parse flags
381382
flag.StringVar(&configFile, "config", configFile, "")
382383
flag.StringVar(&configFile, "c", configFile, "")
383384
flag.StringVar(&rootPath, "root", rootPath, "")
384385
flag.StringVar(&rootPath, "r", rootPath, "")
386+
flag.BoolVar(&showHelp, "help", showHelp, "")
387+
flag.BoolVar(&showHelp, "h", showHelp, "")
385388
flag.Parse()
386389

387390
command := os.Args[len(os.Args)-1]
388-
if command != "build" && command != "serve" && command != "new" {
391+
if showHelp || (command != "build" && command != "serve" && command != "new") {
389392
fmt.Printf(`Gozer - a fast & simple static site generator
390393
391394
Usage: gozer [OPTIONS] <COMMAND>

0 commit comments

Comments
 (0)