Skip to content

Commit 27e07f0

Browse files
authored
feat: #234 support kingpin.CmdClause as argument (#238)
Signed-off-by: fengxusong <[email protected]>
1 parent 727d9c1 commit 27e07f0

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

web/kingpinflag/flag.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,16 @@ import (
1919
"github.com/prometheus/exporter-toolkit/web"
2020
)
2121

22-
// AddFlags adds the flags used by this package to the Kingpin application.
22+
type flagGroup interface {
23+
Flag(string, string) *kingpin.FlagClause
24+
}
25+
26+
var _ flagGroup = &kingpin.Application{}
27+
28+
// AddFlags adds the flags used by this package to the Kingpin application or CmdClause.
2329
// To use the default Kingpin application, call
2430
// AddFlags(kingpin.CommandLine, ":portNum") where portNum is the default port.
25-
func AddFlags(a *kingpin.Application, defaultAddress string) *web.FlagConfig {
31+
func AddFlags(a flagGroup, defaultAddress string) *web.FlagConfig {
2632
systemdSocket := func() *bool { b := false; return &b }() // Socket activation only available on Linux
2733
if runtime.GOOS == "linux" {
2834
systemdSocket = a.Flag(

0 commit comments

Comments
 (0)