Skip to content

Commit

Permalink
gateway: fix formatting
Browse files Browse the repository at this point in the history
Change-Id: I98bfca25e951e2722fcb233b1a6ee2d7c795d0fa
  • Loading branch information
egonelbre committed Oct 31, 2022
1 parent c749f6e commit 38bdaef
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions main.go
Expand Up @@ -356,14 +356,15 @@ func (flags GatewayFlags) nonInteractive(cmd *cobra.Command, setupDir string, ov
process.SaveConfigRemovingDeprecated()))
}

/* `setUsageFunc` is a bit unconventional but cobra didn't leave much room for
extensibility here. `cmd.SetUsageTemplate` is fairly useless for our case without
the ability to add to the template's function map (see: https://golang.org/pkg/text/template/#hdr-Functions).
Because we can't alter what `cmd.Usage` generates, we have to edit it afterwards.
In order to hook this function *and* get the usage string, we have to juggle the
`cmd.usageFunc` between our hook and `nil`, so that we can get the usage string
from the default usage func.
/*
`setUsageFunc` is a bit unconventional but cobra didn't leave much room for
extensibility here. `cmd.SetUsageTemplate` is fairly useless for our case without
the ability to add to the template's function map (see: https://golang.org/pkg/text/template/#hdr-Functions).
Because we can't alter what `cmd.Usage` generates, we have to edit it afterwards.
In order to hook this function *and* get the usage string, we have to juggle the
`cmd.usageFunc` between our hook and `nil`, so that we can get the usage string
from the default usage func.
*/
func setUsageFunc(cmd *cobra.Command) {
if findBoolFlagEarly("advanced") {
Expand Down

0 comments on commit 38bdaef

Please sign in to comment.