Skip to content

Commit

Permalink
Add short flags to help, add --help flag
Browse files Browse the repository at this point in the history
This prints the short variants (like `-c` for `--config`)
in the help.

Also fixes bug where only `-h` flag works, not `--help`.
  • Loading branch information
ginger51011 committed Jan 20, 2024
1 parent 4b8f080 commit 82d2de9
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion internal/config/arguments.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ func argParse() {
continue
}
switch arg {
case "-h":
case "-h", "--help":
CLI.printUsage()
case "-c", "--config":
if len(os.Args) < i+2 {
Expand Down
6 changes: 3 additions & 3 deletions internal/config/help.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@ var CLI = help{
title: Title,
version: Version,
usage: map[int][]string{
0: {0: "--config", 1: "<file>", 2: "Specify config file"},
0: {0: "-c, --config", 1: "<file>", 2: "Specify config file"},
1: {0: "--nocolor", 1: "disable color and banner"},
2: {0: "--banner", 1: "show banner + version and exit"},
3: {0: "--genconfig", 1: "write default config to " + Title + ".toml then exit"},
4: {0: "--book", "<file>", "Specify a custom file used for text generation"},
5: {0: "--help", 1: "show this help and exit"},
4: {0: "-b, --book", 1: "<file>", 2: "Specify a custom file used for text generation"},
5: {0: "-h, --help", 1: "show this help and exit"},
},
out: os.Stdout,
}
Expand Down

0 comments on commit 82d2de9

Please sign in to comment.