Skip to content

Commit

Permalink
feat: #234 support kingpin.CmdClause as argument (#238)
Browse files Browse the repository at this point in the history
Signed-off-by: fengxusong <[email protected]>
  • Loading branch information
fengxsong authored Sep 1, 2024
1 parent 727d9c1 commit 27e07f0
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions web/kingpinflag/flag.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,16 @@ import (
"github.com/prometheus/exporter-toolkit/web"
)

// AddFlags adds the flags used by this package to the Kingpin application.
type flagGroup interface {
Flag(string, string) *kingpin.FlagClause
}

var _ flagGroup = &kingpin.Application{}

// AddFlags adds the flags used by this package to the Kingpin application or CmdClause.
// To use the default Kingpin application, call
// AddFlags(kingpin.CommandLine, ":portNum") where portNum is the default port.
func AddFlags(a *kingpin.Application, defaultAddress string) *web.FlagConfig {
func AddFlags(a flagGroup, defaultAddress string) *web.FlagConfig {
systemdSocket := func() *bool { b := false; return &b }() // Socket activation only available on Linux
if runtime.GOOS == "linux" {
systemdSocket = a.Flag(
Expand Down

0 comments on commit 27e07f0

Please sign in to comment.