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

35 lines
727 B
Go
Raw Normal View History

2023-04-24 20:52:12 +02:00
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: "name",
Usage: "use `NAME` as targeted proxy",
Value: "",
Required: true,
},
)
flags = append(flags, baseFlags...)
return flags
}
func AssertProxyName(ctx *cli.Context) (store.ProxyName, error) {
rawProxyName := ctx.String("name")
name, err := store.ValidateName(rawProxyName)
if err != nil {
return "", errors.WithStack(err)
}
return store.ProxyName(name), nil
}