Skip to content

Nested yaml structures #1781

Answered by kjeom
binwiederhier asked this question in Q&A
Discussion options

You must be logged in to vote

Hi @binwiederhier
Of course you can make the yaml file like that.
But I'm not sure the object that has child hierarchy can become a list.
You can use leaf values as a list. So I think you need to remove the '-'.

anyway you can use the hierarchy like following.

"github.com/urfave/cli/v2"

func main() {
        flags := []cli.Flag{
		&cli.StringFlag{
			Name:  "config",
			Usage: "yaml config file name",
		},
		altsrc.NewStringFlag(
			&cli.StringFlag{
				Name:        "converters.github.title",
				Aliases:     []string{},
				Value:       "",
			},
		),
	}
        app := &cli.App{
		Flags:  flags,
		Before: altsrc.InitInputSourceWithContext(flags, altsrc.NewYamlSourceFromFlagFunc("config")…

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by kjeom
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants