Skip to content

Commit

Permalink
introduce plugin.RunningStandalone as utility func for a plugin to kn…
Browse files Browse the repository at this point in the history
…ow it is run standalone

Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
  • Loading branch information
ndeloof committed Feb 23, 2022
1 parent cf8c4ba commit d9a2a55
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions cli-plugins/plugin/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -160,3 +160,11 @@ func newMetadataSubcommand(plugin *cobra.Command, meta manager.Metadata) *cobra.
}
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
}

0 comments on commit d9a2a55

Please sign in to comment.