diff --git a/cmd/client.go b/cmd/client.go index 87d9b89..b5260d1 100644 --- a/cmd/client.go +++ b/cmd/client.go @@ -13,8 +13,10 @@ var clientCmd = &cobra.Command{ func init() { rootCmd.AddCommand(clientCmd) natsFlags(clientCmd) + clientFlags(clientCmd) } func bindClientCmdFlags(cmd *cobra.Command, args []string) { bindNatsFlags(cmd) + bindClientFlags(cmd) } diff --git a/cmd/flags.go b/cmd/flags.go index 9395012..436f75f 100644 --- a/cmd/flags.go +++ b/cmd/flags.go @@ -31,6 +31,14 @@ func natsFlags(cmd *cobra.Command) { cmd.PersistentFlags().Bool("use-traffic-shaping", false, "Local development connection") } +func bindClientFlags(cmd *cobra.Command) { + viper.BindPFlag("inbox_prefix", cmd.Flags().Lookup("inbox-prefix")) +} + +func clientFlags(cmd *cobra.Command) { + cmd.PersistentFlags().String("inbox-prefix", "PIGGYBANK.ADMIN", "subject prefix for replies") +} + // bindServiceFlags binds the secret flag values to viper func bindServiceFlags(cmd *cobra.Command) { viper.BindPFlag("port", cmd.Flags().Lookup("port")) diff --git a/cmd/nats.go b/cmd/nats.go index b185d46..a3b1d95 100644 --- a/cmd/nats.go +++ b/cmd/nats.go @@ -10,7 +10,7 @@ import ( ) func newNatsConnection(name string) (*nats.Conn, error) { - opts := []nats.Option{nats.Name(name)} + opts := []nats.Option{nats.Name(name), nats.CustomInboxPrefix(viper.GetString("inbox_prefix"))} _, ok := os.LookupEnv("USER")