Add plugins required flag (#40)

* add required plugins flag.

* update plugins logs.

* add plugins subcommand.

* move preflight to prerun.
This commit is contained in:
Miroslav Šedivý 2023-03-31 12:02:33 +02:00 committed by GitHub
parent 43a649d2c4
commit 1a752e43d2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 197 additions and 85 deletions

View file

@ -6,8 +6,9 @@ import (
)
type Plugins struct {
Enabled bool
Dir string
Enabled bool
Dir string
Required bool
}
func (Plugins) Init(cmd *cobra.Command) error {
@ -21,10 +22,16 @@ func (Plugins) Init(cmd *cobra.Command) error {
return err
}
cmd.PersistentFlags().Bool("plugins.required", false, "if true, neko will exit if there is an error when loading a plugin")
if err := viper.BindPFlag("plugins.required", cmd.PersistentFlags().Lookup("plugins.required")); err != nil {
return err
}
return nil
}
func (s *Plugins) Set() {
s.Enabled = viper.GetBool("plugins.enabled")
s.Dir = viper.GetString("plugins.dir")
s.Required = viper.GetBool("plugins.required")
}