Merge pull request #3437 from ndeloof/cli-plugin-standalone

introduce plugin.RunningStandalone utility func
This commit is contained in:
Sebastiaan van Stijn 2022-02-24 17:50:49 +01:00 committed by GitHub
commit 531810bb1b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 8 additions and 0 deletions

View File

@ -160,3 +160,11 @@ func newMetadataSubcommand(plugin *cobra.Command, meta manager.Metadata) *cobra.
} }
return cmd return cmd
} }
// RunningStandalone tells a CLI plugin it is run standalone by direct execution
func RunningStandalone() bool {
if os.Getenv(manager.ReexecEnvvar) != "" {
return false
}
return len(os.Args) < 2 || os.Args[1] != manager.MetadataSubcommandName
}