mirror of
https://github.com/m1k1o/neko.git
synced 2025-05-23 14:07:06 +02:00
Add plugins required flag (#40)
* add required plugins flag. * update plugins logs. * add plugins subcommand. * move preflight to prerun.
This commit is contained in:
parent
43a649d2c4
commit
1a752e43d2
6 changed files with 197 additions and 85 deletions
|
@ -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")
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue