(Go: >> BACK << -|- >> HOME <<)

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

similar to subcommand, I would like to have subarg #126

Open
kernel164 opened this issue Oct 1, 2020 · 7 comments
Open

similar to subcommand, I would like to have subarg #126

kernel164 opened this issue Oct 1, 2020 · 7 comments

Comments

@kernel164
Copy link

Here is the idea...

type MainOpts struct {
	Port    int `arg:"--port"`
	Inner InnerOpts `arg:"subarg:inner"`
}
type InnerOpts struct {
	Enabled bool `arg:"enabled"`
}

should become

--port
--inner-enabled

Don't know whether it is already supported but this nicely fits in for nested structs.
It's similar to custom parsing for values but for arg names.

@alexflint
Copy link
Owner

Yes this is do-able but I fear that it would add more complexity than it's worth, and would make it more difficult to understand code that uses this library. Are there really cases when you want to repeat a significant number of inner options at different places within the same program?

@kernel164
Copy link
Author

Our requirement is similar to this => https://doc.traefik.io/traefik/v2.3/reference/static-configuration/cli/

possibly there could be 3 or 4 levels of inner struct.

@kernel164
Copy link
Author

we used kingpin => https://github.com/alecthomas/kingpin but we would like to move to go-arg.

Idea is to have go-arg,config(yaml,json.. etc) parse into same struct.

@alexflint
Copy link
Owner

Got it. Seems reasonable, and fun to implement :). I'm about to go into a meditation retreat but will try to find time for this afterwards.

@alexflint
Copy link
Owner

Would you be interested in providing some funding to me in order to implement this feature?

@kernel164
Copy link
Author

I just do opensource projects like you. I started using go-arg for my new codes. thought of having this feature in my new projects. I can contribute as code though.

@alexflint
Copy link
Owner

OK @kernel164, I'd be happy to review a pull request

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