Skip to content

Commit

Permalink
Default help command
Browse files Browse the repository at this point in the history
  • Loading branch information
hedhyw committed Jan 15, 2022
1 parent b9cf979 commit 011f684
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
2 changes: 1 addition & 1 deletion internal/app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ func Run(arguments []string, out io.Writer) (err error) {
switch {
case *list:
return runListTemplates(out)
case *help:
case *help, inputFile == "":
return runHelp()
default:
return runGenerator(out, enums.Format(*outputFormat), *templateFile, inputFile)
Expand Down
10 changes: 8 additions & 2 deletions internal/app/help.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
package app

import "flag"
import (
"flag"
"fmt"
"os"
)

func runHelp() (err error) {
flag.Usage()
fmt.Fprintf(flag.CommandLine.Output(), "Usage of %s [FILE]:\n", os.Args[0])
flag.PrintDefaults()
fmt.Fprintf(flag.CommandLine.Output(), "\nExample: %s example.feature >> example_test.go\n", os.Args[0])

return nil
}

0 comments on commit 011f684

Please sign in to comment.