Skip to content

Commit

Permalink
feat(cli): '--help' flag
Browse files Browse the repository at this point in the history
this flag works the same way as calling fleck without any arguments, but omits the error at the end. A help page is somewhat standard, therefore i added this option / flag
  • Loading branch information
xNaCly committed Apr 17, 2023
1 parent 9ddb059 commit 24654d8
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 0 deletions.
6 changes: 6 additions & 0 deletions cli/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,12 @@ func (a *Arguments) String() string {
}

var OPTIONS []Flag = []Flag{
{
"help",
false,
"prints the help page, exists",
"",
},
{
"debug",
false,
Expand Down
2 changes: 2 additions & 0 deletions doc/Usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ Usage:
fleck [Options] file
Options:
--help prints the help page, exists
--debug enables debug logs
--version prints version and build information, exists
--no-prefix hide the informational comments generated in the output html
Expand All @@ -41,6 +42,7 @@ exit status 1

| Option | description | default value |
| ------------------------ | ----------------------------------------------------------------- | ------------- |
| `--help` | prints the help page, exists | false |
| `--debug` | enables debug logs | false |
| `--version` | prints version and build information, exists | false |
| `--no-prefix` | hide the informational comments generated in the output html | false |
Expand Down
4 changes: 4 additions & 0 deletions fleck.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ func main() {
if cli.GetFlag(cli.ARGUMENTS, "version") {
cli.PrintVersion(VERSION, BUILD_AT, BUILD_BY)
}
if cli.GetFlag(cli.ARGUMENTS, "help") {
cli.PrintShortHelp()
os.Exit(0)
}
if len(cli.ARGUMENTS.InputFile) == 0 {
cli.PrintShortHelp()
logger.LError("not enough arguments, specify an input file")
Expand Down

0 comments on commit 24654d8

Please sign in to comment.