-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
caddycmd.Commands() function doesn't work #6819
Comments
Hmm, @mohammed90 maybe we should look into this when we have a sec.
That seems like less of a program concern and more of a shell concern. I would just append this to your command (bash): |
Hi @mholt , Thanks for your reply. Unfortunately, I don't run caddy in bash. I am trying to compile and run caddy in go test, just like the way at https://github.com/caddyserver/caddy/blob/master/caddytest/caddytest.go#L268
|
Regardless of which shell or execution environment, I feel like redirecting stdout/stderr is the concern of the shell or execution environment, rather than the program being executed. It's also going to be much simpler that way. We'll look into the empty map thing though. |
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 byRegisterCommand
.But actually, the
RegisterCommand
function doesn't set the command into thecommands
map. It only reads from thecommands
map. So the funcionCommands()
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?The text was updated successfully, but these errors were encountered: