We have an app which receives an urfave cli context object in a func:
import "gopkg.in/urfave/cli.v1"
func runApp(ctx *cli.Context) {
cache := ctx.GlobalInt(MyFlag.Name)
.... // do more stuff
}
I am trying to call runApp without the whole cli stuff, directly from code. Hence I have to build the ctx manually:
func MyTest() {
fs := flag.NewFlagSet("", flag.ExitOnError)
app := cli.NewApp()
fs.Set(MyFlag.Name, "5000")
ctx := cli.NewContext(app, fs, nil)
runApp(ctx)
}
But it actually looks like the flag is never set, runApp never sees the value I set by hand.
What am I doing wrong? Can this actually be done at all?