Motivation & Context
I have the following code:
app := cli.NewApp()
app.Name = "myprogramname"
I then add a sub command with the name "foo", and in that sub command I run:
func fooAction(c *cli.Context) error {
program := c.App.Name
log.Printf("program is: %s", program)
}
Unfortunately this prints "program is: myprogramname foo" instead of leaving out the "foo".
This is unexpected, particularly because the "program" did not change. If it is desired to have some sort of variable that appends the sub command names on it, then it should be something different. I use this variable to ascertain the "base name" of the program reliably, for log messages, etc...
Requested Change
Add an app.ProgramName, that is always myprogramname, regardless of whether or not a particular subcommand is being executed.
heavily edited by @lynncyrin!
Motivation & Context
I have the following code:
I then add a sub command with the name "foo", and in that sub command I run:
Unfortunately this prints "program is:
myprogramname foo" instead of leaving out the "foo".This is unexpected, particularly because the "program" did not change. If it is desired to have some sort of variable that appends the sub command names on it, then it should be something different. I use this variable to ascertain the "base name" of the program reliably, for log messages, etc...
Requested Change
Add an
app.ProgramName, that is alwaysmyprogramname, regardless of whether or not a particular subcommand is being executed.heavily edited by @lynncyrin!