I try to write my first CLI App in Go.
I use codegangsta/cli for the structure.
My problem :
I have some commands :
Add --name
Show --all
Delete --force
From the file /commands/add.go I can't get the variable StackName
from /commands.go set like this :
package main
var StackName string
var Commands = []cli.Command{
{
Name: "add",
Usage: "",
Action: command.CmdAdd,
Flags: []cli.Flag{
cli.StringFlag{
Name: "name, n",
Value: "default",
Usage: "Stack name",
Destination: &StackName,
},
And in my add.go file, I try to get $stackName but I don't find how to do this :
package command
func CmdAdd(c *cli.Context) {
fmt.PrintF(StackName)
}
I got this : command/add.go:25: undefined: StackName
.
Thanks to help to find where I'm wrong.