Skip to content
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

Using env with cmd does not appear to work as expected. #417

Open
nullism opened this issue Mar 1, 2024 · 3 comments
Open

Using env with cmd does not appear to work as expected. #417

nullism opened this issue Mar 1, 2024 · 3 comments

Comments

@nullism
Copy link

nullism commented Mar 1, 2024

Hello all!

Playground demonstrating the issue: https://go.dev/play/p/LFPIRwbTCqc

If we had a struct like:

var CLI struct {
    One CmdOne `cmd:"" env:"CMD"`
    Two CmdTwo `cmd:"" env:"CMD"`
}

Then env CMD=one cli still fails with expected one of "one", "two" which doesn't seem correct to me. Perhaps I'm missing something in the usage?

However, cli one or cli two works as expected.

Thanks for your time!

PS:

I know we can do something like this, but it seems to defeat the purpose of env:"X":

	if cmd := os.Getenv("CMD"); cmd != "" {
		os.Args = append([]string{os.Args[0], cmd}, os.Args[1:]...)
	}
@nullism
Copy link
Author

nullism commented Mar 1, 2024

If using env with cmd is not intended to be supported, could we get Kong to produce an error when both are specified?

@alecthomas
Copy link
Owner

env is not supported, correct. Kong currently doesn't error for any use of unsupported tags. I think doing that robustly would require some thought.

@nullism
Copy link
Author

nullism commented Mar 1, 2024

Ah, I haven't dug into the code, but sounds like it's more involved than just checking if cmd and env then error.

Thanks very much for the reply. Love the package!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants