Skip to content

Commit ee2a1f9

Browse files
committed
Update freno help message handling
Currently the default behavior for running 'freno -help' is to emit a panic. This overrides the default behavior of the flag package and makes it so there's no way to see the list of program options. There is a program-specific usage message which is emitted when there are no arguments. There's no reason to have separate behavior for this usage message and -help output, so this PR combines emiting program options with the custom usage message and gives this behavior to the 'no options' default program behavior and the '-help' argument. This ensures that default expected behavior matched the actual program behavior
1 parent 93523b2 commit ee2a1f9

File tree

2 files changed

+14
-18
lines changed

2 files changed

+14
-18
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@ bin/
33
main
44
conf/freno.local.conf.json
55
.vendor/
6+
freno

go/cmd/freno/main.go

Lines changed: 13 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ func main() {
4343
group.ForceLeadership = *forceLeadership
4444

4545
if *help {
46-
printHelp()
46+
printUsage()
4747
return
4848
}
4949

@@ -83,8 +83,6 @@ func main() {
8383
case *http:
8484
err := httpServe()
8585
log.Errore(err)
86-
case *help:
87-
printHelp()
8886
default:
8987
printUsage()
9088
}
@@ -126,25 +124,22 @@ func httpServe() error {
126124
return gohttp.ListenAndServe(fmt.Sprintf(":%d", port), router)
127125
}
128126

129-
func printHelp() {
130-
panic("not yet implemented")
131-
}
132-
133127
func printUsage() {
134128
fmt.Println(`Usage: freno [OPTIONS]
135-
To run the freno service, execute:
136-
freno --http
129+
To run the freno service, execute:
130+
freno --http
137131
138-
For more help options use: freno -help.
139-
140-
freno is a free and open source software.
141-
Please see https://github.com/github/freno/blob/master/README.md#license for license.
142-
Sources and binaries are found on https://github.com/github/freno/releases.
143-
Sources are also available by cloning https://github.com/github/freno.
132+
freno is a free and open source software.
133+
Please see https://github.com/github/freno/blob/master/README.md#license for license.
134+
Sources and binaries are found on https://github.com/github/freno/releases.
135+
Sources are also available by cloning https://github.com/github/freno.
144136
145137
Issues can be sumbitted on https://github.com/github/freno/issues
146-
Please see https://github.com/github/freno/blob/master/README.md#contributing for contributions
138+
Please see https://github.com/github/freno/blob/master/README.md#contributing for contributions
139+
140+
Authored by GitHub engineering
141+
142+
OPTIONS:`)
147143

148-
Authored by GitHub engineering
149-
`)
144+
flag.PrintDefaults()
150145
}

0 commit comments

Comments
 (0)