You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
feat: add ability to get command information from *State #4
I currently handle retrieving flags (or env variables) from my application. I am able to print out something like:
error: must provide --dir flag or set DIR environment variable
However, it'd be nice if the command name could be printed so the error looks something like this (notice the extra command information):
error: command "goose status": must provide --dir flag or set DIR environment variable
This is currently not possible because path []*Command is unexported on the *State, and that object is the only thing available in Exec functions. We should consider exporting it, or adding a method to retrieve either the full command path or just the terminal command.
One solution could be to expose what's needed, but I'm not yet sure how much from the *Command is needed?
// CommandPath returns the full command path as a space-separated string, e.g., "goose status".func (s*State) CommandPath() string {
returngetCommandPath(s.path)
}
// CommandName returns the name of the terminal (current) command being executed.func (s*State) CommandName() string {
iflen(s.path) ==0 {
return""
}
returns.path[len(s.path)-1].Name
}
Activity
mfridman commentedon Feb 16, 2026
One solution could be to expose what's needed, but I'm not yet sure how much from the
*Commandis needed?