Skip to content

Add an App.ProgramName #783

Description

@purpleidea

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!

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/v2relates to / is being considered for v2kind/discussionis for discussionkind/featuredescribes a code enhancement / feature requeststatus/confirmedconfirmed to be valid, but work has yet to start

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions