Skip to content

Commit 9c934a4

Browse files
committed
set default value for client inbox
1 parent ed8c2a7 commit 9c934a4

File tree

3 files changed

+11
-1
lines changed

3 files changed

+11
-1
lines changed

cmd/client.go

+2
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,10 @@ var clientCmd = &cobra.Command{
1313
func init() {
1414
rootCmd.AddCommand(clientCmd)
1515
natsFlags(clientCmd)
16+
clientFlags(clientCmd)
1617
}
1718

1819
func bindClientCmdFlags(cmd *cobra.Command, args []string) {
1920
bindNatsFlags(cmd)
21+
bindClientFlags(cmd)
2022
}

cmd/flags.go

+8
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,14 @@ func natsFlags(cmd *cobra.Command) {
3131
cmd.PersistentFlags().Bool("use-traffic-shaping", false, "Local development connection")
3232
}
3333

34+
func bindClientFlags(cmd *cobra.Command) {
35+
viper.BindPFlag("inbox_prefix", cmd.Flags().Lookup("inbox-prefix"))
36+
}
37+
38+
func clientFlags(cmd *cobra.Command) {
39+
cmd.PersistentFlags().String("inbox-prefix", "PIGGYBANK.ADMIN", "subject prefix for replies")
40+
}
41+
3442
// bindServiceFlags binds the secret flag values to viper
3543
func bindServiceFlags(cmd *cobra.Command) {
3644
viper.BindPFlag("port", cmd.Flags().Lookup("port"))

cmd/nats.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import (
1010
)
1111

1212
func newNatsConnection(name string) (*nats.Conn, error) {
13-
opts := []nats.Option{nats.Name(name)}
13+
opts := []nats.Option{nats.Name(name), nats.CustomInboxPrefix(viper.GetString("inbox_prefix"))}
1414

1515
_, ok := os.LookupEnv("USER")
1616

0 commit comments

Comments
 (0)