3
0

Disable initialization on some commands

This commit is contained in:
Denis Arh
2020-03-27 22:00:10 +01:00
parent c0713893b6
commit fe0e35cb57

View File

@@ -36,6 +36,13 @@ var (
Use: "version",
Short: "Version",
}
// List of commands that do not
// run initialization (db connection, etc...)
light = map[string]bool{
"help": true,
versionCommand.Use: true,
}
)
// RootCommand creates root command with a simple persistent-pre-run callback
@@ -50,7 +57,7 @@ func RootCommand(ppRunEfn func() error) *cobra.Command {
)
cmd.PersistentPreRunE = func(cmd *cobra.Command, args []string) (err error) {
if cmd.Name() == "help" {
if light[cmd.Name()] {
// Do not run hooks on parts on help command
return nil
}