-
-
Notifications
You must be signed in to change notification settings - Fork 4.7k
caddycmd.Commands() function doesn't work #6819
Description
In https://github.com/caddyserver/caddy/blob/9996d6a70ba76a94dfc90548f25fbac0ce9da497/cmd/commands.go#L80C1-L86C40. There is a function Commands() to get a list of commands initialised by RegisterCommand.
// Commands returns a list of commands initialised by
// RegisterCommand
func Commands() map[string]Command {
return commands
}
var commands = make(map[string]Command)
But actually, the RegisterCommand function doesn't set the command into the commands map. It only reads from the commands map. So the funcion Commands() always return an empty map.
I wonder if the Commands() function still works.
By the way, I want to use the Commands() function get the caddy run command. Then I need to overwrite the original caddy run function to redirect its output to somewhere to remove its stdout/stderr from OS.Stdout/os.Stderr. Its output interferes with the go test output. Do you have any recommendations to achieve this?