bouncer/internal/command/api/inbound/flag/flag.go

35 lines
741 B
Go

package flag
import (
"errors"
clientFlag "forge.cadoles.com/cadoles/bouncer/internal/command/api/flag"
"forge.cadoles.com/cadoles/bouncer/internal/datastore"
"github.com/urfave/cli/v2"
)
func WithInboundFlags(flags ...cli.Flag) []cli.Flag {
baseFlags := clientFlag.ComposeFlags(
&cli.StringFlag{
Name: "inbound-id",
Aliases: []string{"in"},
Usage: "use `INBOUND_ID` as selected inbound",
Value: "",
},
)
flags = append(flags, baseFlags...)
return flags
}
func AssertInboundID(ctx *cli.Context) (datastore.InboundID, error) {
rawInboundID := ctx.String("inbound-id")
if rawInboundID == "" {
return "", errors.New("flag 'inbound-id' is required")
}
return datastore.InboundID(rawInboundID), nil
}