Skip to content

Commit

Permalink
Allow passing bridge-specific config generation params as flags
Browse files Browse the repository at this point in the history
  • Loading branch information
tulir committed Jun 22, 2023
1 parent 75ccf4b commit f855dbf
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions cmd/bbctl/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,11 @@ var configCommand = &cli.Command{
EnvVars: []string{"BEEPER_BRIDGE_TYPE"},
Usage: "The type of bridge being registered.",
},
&cli.StringSliceFlag{
Name: "param",
Aliases: []string{"p"},
Usage: "Set a bridge-specific config generation option. Can be specified multiple times for different keys. Format: key=value",
},
&cli.StringFlag{
Name: "output",
Aliases: []string{"o"},
Expand Down Expand Up @@ -114,6 +119,13 @@ func generateBridgeConfig(ctx *cli.Context) error {
}
extraParamAsker := askParams[bridgeType]
extraParams := make(map[string]any)
for _, item := range ctx.StringSlice("param") {
parts := strings.SplitN(item, "=", 2)
if len(parts) != 2 {
return UserError{fmt.Sprintf("Invalid param %q", item)}
}
extraParams[strings.ToLower(parts[0])] = parts[1]
}
if extraParamAsker != nil {
err = extraParamAsker(extraParams)
if err != nil {
Expand Down

0 comments on commit f855dbf

Please sign in to comment.