go-arg icon indicating copy to clipboard operation
go-arg copied to clipboard

similar to subcommand, I would like to have subarg

Open kernel164 opened this issue 5 years ago • 7 comments

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.

kernel164 avatar Oct 01 '20 07:10 kernel164

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?

alexflint avatar Oct 03 '20 17:10 alexflint

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 avatar Oct 05 '20 12:10 kernel164

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.

kernel164 avatar Oct 08 '20 13:10 kernel164

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 avatar Oct 09 '20 18:10 alexflint

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

alexflint avatar Oct 09 '20 18:10 alexflint

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.

kernel164 avatar Oct 14 '20 14:10 kernel164

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

alexflint avatar Nov 02 '20 20:11 alexflint