Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support kingpin.CmdClause as argument #238

Merged
merged 1 commit into from
Sep 1, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading