Skip to content

Commit f20260a

Browse files
authored
Merge pull request #103 from hookdeck/refactor-config
refactor: Config parsing & precedence
2 parents 296daf3 + d5e33d0 commit f20260a

17 files changed

Lines changed: 746 additions & 251 deletions

README.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,29 @@ Inventory Service forwarding to /webhooks/shopify/inventory
133133
Orders Service forwarding to /webhooks/shopify/orders
134134

135135

136+
⣾ Getting ready...
137+
138+
```
139+
140+
#### Listen to multiple sources
141+
142+
`source-alias` can be a comma-separated list of source names (for example, `stripe,shopify,twilio`) or `'*'` (with quotes) to listen to all sources.
143+
144+
```sh-session
145+
$ hookdeck listen 3000 '*'
146+
147+
👉 Inspect and replay events: https://dashboard.hookdeck.com/cli/events
148+
149+
Sources
150+
🔌 stripe URL: https://events.hookdeck.com/e/src_DAjaFWyyZXsFdZrTOKpuHn01
151+
🔌 shopify URL: https://events.hookdeck.com/e/src_DAjaFWyyZXsFdZrTOKpuHn02
152+
🔌 twilio URL: https://events.hookdeck.com/e/src_DAjaFWyyZXsFdZrTOKpuHn03
153+
154+
Connections
155+
stripe -> cli-stripe forwarding to /webhooks/stripe
156+
shopify -> cli-shopify forwarding to /webhooks/shopify
157+
twilio -> cli-twilio forwarding to /webhooks/twilio
158+
136159
⣾ Getting ready...
137160

138161
```

pkg/cmd/listen.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ func normalizeCliPathFlag(f *pflag.FlagSet, name string) pflag.NormalizedName {
3838
switch name {
3939
case "cli-path":
4040
name = "path"
41-
break
4241
}
4342
return pflag.NormalizedName(name)
4443
}

pkg/cmd/project_use.go

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@ import (
55
"github.com/spf13/cobra"
66

77
"github.com/hookdeck/hookdeck-cli/pkg/hookdeck"
8-
"github.com/hookdeck/hookdeck-cli/pkg/validators"
98
"github.com/hookdeck/hookdeck-cli/pkg/project"
9+
"github.com/hookdeck/hookdeck-cli/pkg/validators"
1010
)
1111

1212
type projectUseCmd struct {
13-
cmd *cobra.Command
14-
local bool
13+
cmd *cobra.Command
14+
// local bool
1515
}
1616

1717
func newProjectUseCmd() *projectUseCmd {
@@ -23,7 +23,10 @@ func newProjectUseCmd() *projectUseCmd {
2323
Short: "Select your active project for future commands",
2424
RunE: lc.runProjectUseCmd,
2525
}
26-
lc.cmd.Flags().BoolVar(&lc.local, "local", false, "Pin active project to the current directory")
26+
27+
// With the change in config management (either local or global, not both), this flag is no longer needed
28+
// TODO: consider remove / deprecate
29+
// lc.cmd.Flags().BoolVar(&lc.local, "local", false, "Pin active project to the current directory")
2730

2831
return lc
2932
}
@@ -74,5 +77,5 @@ func (lc *projectUseCmd) runProjectUseCmd(cmd *cobra.Command, args []string) err
7477
}
7578
}
7679

77-
return Config.UseProject(lc.local, project.Id, project.Mode)
80+
return Config.UseProject(project.Id, project.Mode)
7881
}

pkg/cmd/root.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ func init() {
9191
rootCmd.PersistentFlags().StringVar(&Config.Profile.APIKey, "cli-key", "", "(deprecated) Your API key to use for the command")
9292
rootCmd.PersistentFlags().StringVar(&Config.Profile.APIKey, "api-key", "", "Your API key to use for the command")
9393
rootCmd.PersistentFlags().StringVar(&Config.Color, "color", "", "turn on/off color output (on, off, auto)")
94-
rootCmd.PersistentFlags().StringVar(&Config.LocalConfigFile, "config", "", "config file (default is $HOME/.config/hookdeck/config.toml)")
94+
rootCmd.PersistentFlags().StringVar(&Config.ConfigFileFlag, "config", "", "config file (default is $HOME/.config/hookdeck/config.toml)")
9595
rootCmd.PersistentFlags().StringVar(&Config.DeviceName, "device-name", "", "device name")
9696
rootCmd.PersistentFlags().StringVar(&Config.LogLevel, "log-level", "info", "log level (debug, info, warn, error)")
9797
rootCmd.PersistentFlags().BoolVar(&Config.Insecure, "insecure", false, "Allow invalid TLS certificates")

0 commit comments

Comments
 (0)