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
We are trying to construct a plugin that could apply a --plain flag to several CLI tools. The ideal state is that either of the following are vaild:
my-cli --plain
# ...or...
PLAIN=true my-cli
The rough structure of our plugin is the following:
package kongplugin
import (
"github.com/alecthomas/kong""github.com/pterm/pterm"
)
typePlainFlagstruct {
PlainplainFlag`env:"PLAIN" help:"disable styling of the output"`
}
typeplainFlagboolfunc (vplainFlag) IsBool() bool { returntrue }
func (vplainFlag) BeforeApply(ktx*kong.Context) error {
// Disable styling for any of our downstream toolsreturnnil
}
Our main problem with this approach is that the environment variable PLAIN does not get respected by this approach, primarily because it appears Kong will not run any of plainFlag's hooks unless the flag is explicitly declared. We have tried the following:
Leverage all lifecycle hooks supported by Kong
Customer Resolver configurations to respect the default
Are there any recommendations of how we could get this functionality?
The text was updated successfully, but these errors were encountered:
Unfortunately, we ended up needing to duplicate the code in several CLIs we manage, sharing only the definition of the flag. Still hoping to hear guidance from the Kong team on a better approach.
We are trying to construct a plugin that could apply a
--plain
flag to several CLI tools. The ideal state is that either of the following are vaild:my-cli --plain # ...or... PLAIN=true my-cli
The rough structure of our plugin is the following:
Our main problem with this approach is that the environment variable
PLAIN
does not get respected by this approach, primarily because it appears Kong will not run any ofplainFlag
's hooks unless the flag is explicitly declared. We have tried the following:Resolver
configurations to respect the defaultAre there any recommendations of how we could get this functionality?
The text was updated successfully, but these errors were encountered: