mirror of
https://github.com/m1k1o/neko.git
synced 2025-05-28 16:37:15 +02:00
replace modules with go plugins.
This commit is contained in:
parent
f447cabe2e
commit
a4bb108168
10 changed files with 587 additions and 74 deletions
30
internal/config/plugins.go
Normal file
30
internal/config/plugins.go
Normal file
|
@ -0,0 +1,30 @@
|
|||
package config
|
||||
|
||||
import (
|
||||
"github.com/spf13/cobra"
|
||||
"github.com/spf13/viper"
|
||||
)
|
||||
|
||||
type Plugins struct {
|
||||
Enabled bool
|
||||
Dir string
|
||||
}
|
||||
|
||||
func (Plugins) Init(cmd *cobra.Command) error {
|
||||
cmd.PersistentFlags().Bool("plugins.enabled", false, "load plugins in runtime")
|
||||
if err := viper.BindPFlag("plugins.enabled", cmd.PersistentFlags().Lookup("plugins.enabled")); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
cmd.PersistentFlags().String("plugins.dir", "./bin/plugins", "path to neko plugins to load")
|
||||
if err := viper.BindPFlag("plugins.dir", cmd.PersistentFlags().Lookup("plugins.dir")); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s *Plugins) Set() {
|
||||
s.Enabled = viper.GetBool("plugins.enabled")
|
||||
s.Dir = viper.GetString("plugins.dir")
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue