introduce plugin.RunningStandalone as utility func for a plugin to know it is run standalone

Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
This commit is contained in:
Nicolas De Loof 2022-02-23 10:16:47 +01:00
parent cf8c4bab64
commit d9a2a555d5
No known key found for this signature in database
GPG Key ID: 9858809D6F8F6E7E
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
}