-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Closed
Labels
kind/bugdescribes or fixes a bugdescribes or fixes a bugstatus/confirmedconfirmed to be valid, but work has yet to startconfirmed to be valid, but work has yet to start
Description
Hi,
Unless I'm somehow overlooking something obvious, it seems the new Required support introduced in #819 doesn't work with altsrc.
The following code (based on the example for altsrc) complains that someflag wasn't supported if Required: true, but works if you comment that line out.
package main
import (
"fmt"
"log"
"os"
"github.com/urfave/cli"
"github.com/urfave/cli/altsrc"
)
func main() {
app := cli.NewApp()
flags := []cli.Flag{
altsrc.NewIntFlag(cli.IntFlag{
Name: "someflag",
Required: true,
}),
cli.StringFlag{
Name: "file",
Value: "test_cli_yaml.yaml",
},
}
app.Action = func(c *cli.Context) error {
fmt.Printf("test: %s\n", c.String("someflag"))
return nil
}
app.Before = altsrc.InitInputSourceWithContext(flags, altsrc.NewYamlSourceFromFlagFunc("file"))
app.Flags = flags
err := app.Run(os.Args)
if err != nil {
log.Fatal(err)
}
}And the accompanying YAML file (test_cli_yaml.yaml):
---
someflag: 1@lynncyrin, I suspect your question in #825 might be related to this, right?
coilysiren and 4nte
Metadata
Metadata
Assignees
Labels
kind/bugdescribes or fixes a bugdescribes or fixes a bugstatus/confirmedconfirmed to be valid, but work has yet to startconfirmed to be valid, but work has yet to start