Skip to content

Commit 2e68094

Browse files
authored
feat: add caddyfile debug command (#61)
This PR adds a new `localias debug caddyfile` command to print the current generated Caddyfile config that is being used when you `localias run`. This is useful for debugging issues with that config. Hidden command shouldn't be used by most people but helpful for me when updating Caddy. ## Testing - [x] `localias debug caddyfile` prints a valid config
1 parent 00d590a commit 2e68094

2 files changed

Lines changed: 16 additions & 0 deletions

File tree

TODO

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
should take port :47145 = ALIAS
2+
and make sure to document that it uses a port

cmd/localias/debug/config.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,13 @@ var configFlags struct { //nolint:gochecknoglobals
1313
Print *bool
1414
}
1515

16+
func caddyImpl(_ *cobra.Command, _ []string) error {
17+
cfg := shared.Config()
18+
caddy := cfg.Caddyfile()
19+
fmt.Println(caddy)
20+
return nil
21+
}
22+
1623
func configImpl(_ *cobra.Command, _ []string) error {
1724
cfg := shared.Config()
1825
if *configFlags.Print {
@@ -33,7 +40,14 @@ var configCmd = &cobra.Command{ //nolint:gochecknoglobals
3340
RunE: configImpl,
3441
}
3542

43+
var caddyCmd = &cobra.Command{
44+
Use: "caddyfile",
45+
Short: "show the Caddy configuration file used by localias",
46+
RunE: caddyImpl,
47+
}
48+
3649
func init() {
3750
configFlags.Print = configCmd.Flags().BoolP("print", "p", false, "print the contents of the config file")
3851
Command.AddCommand(configCmd)
52+
Command.AddCommand(caddyCmd)
3953
}

0 commit comments

Comments
 (0)