bouncer/internal/command/client/proxy/flag/flag.go

34 lines
720 B
Go

package flag
import (
clientFlag "forge.cadoles.com/cadoles/bouncer/internal/command/client/flag"
"forge.cadoles.com/cadoles/bouncer/internal/store"
"github.com/pkg/errors"
"github.com/urfave/cli/v2"
)
func WithProxyFlags(flags ...cli.Flag) []cli.Flag {
baseFlags := clientFlag.ComposeFlags(
&cli.StringFlag{
Name: "proxy-id",
Aliases: []string{"p"},
Usage: "use `PROXY_ID` as targeted proxy",
Value: "",
},
)
flags = append(flags, baseFlags...)
return flags
}
func AssertProxyID(ctx *cli.Context) (store.ProxyID, error) {
rawProxyID := ctx.String("proxy-id")
if rawProxyID == "" {
return "", errors.New("'proxy-id' cannot be empty")
}
return store.ProxyID(rawProxyID), nil
}