Nested yaml structures #1781
-
Howdy, Thanks for urfave/cli! I've been using it for years in many projects. Great job! I'd like to know if it is possible to represent something like this with the lib:
I tried fiddling with the Btw, do you have a Discord/chat where one could ask these questions? I couldn't find one. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
Hi @binwiederhier 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")),
Action: func(ctx *cli.Context) error {
fmt.Println(ctx.String("converters.github.title"))
return nil
},
}
fmt.Println(app.Run(os.Args))
} |
Beta Was this translation helpful? Give feedback.
-
@binwiederhier Yes there is a discord server called urfave/cli with channels for v1/v2/v3. |
Beta Was this translation helpful? Give feedback.
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.