Skip to content

Commit

Permalink
chore: add description to usage
Browse files Browse the repository at this point in the history
  • Loading branch information
jar-b committed Sep 15, 2023
1 parent a4da457 commit deb8338
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ go install github.com/jar-b/mdtoc/cmd/mdtoc@latest

```
$ mdtoc -h
Generate a table of contents for an existing markdown document.
Usage: mdtoc [flags] [filename]
Flags:
Expand Down
6 changes: 2 additions & 4 deletions cmd/mdtoc/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,13 @@ var (
tocHeading string = mdtoc.DefaultTocHeading
)

func init() {
func main() {
// slightly better usage output
flag.Usage = func() {
fmt.Fprint(flag.CommandLine.Output(), "Generate a table of contents for an existing markdown document.\n\n")
fmt.Fprintf(flag.CommandLine.Output(), "Usage: %s [flags] [filename]\n\nFlags:\n", os.Args[0])
flag.PrintDefaults()
}
}

func main() {
flag.BoolVar(&force, "force", false, "force overwrite of existing contents (optional)")
flag.BoolVar(&dryRun, "dry-run", false, "print generated contents, but do not write to file (optional)")
flag.StringVar(&out, "out", "", "output file (optional, defaults to adding to source file)")
Expand Down

0 comments on commit deb8338

Please sign in to comment.