-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.go
58 lines (43 loc) · 1.1 KB
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
package main
import (
"log"
"os"
"github.com/FlamesX-128/anigo-plugins/models"
"github.com/FlamesX-128/anigo/controllers/interfaces"
"github.com/FlamesX-128/anigo/controllers/plugins"
"github.com/FlamesX-128/anigo/controllers/surveys"
"github.com/fatih/color"
"golang.org/x/exp/maps"
)
var providers = map[string]models.Provider{}
func init() {
var root string
var err error
if root, err = os.Getwd(); err != nil {
log.Panicln(color.RedString("[Plugin] [Init] [Error] %s", err.Error()))
return
}
// Load plugins.
for _, plugin := range plugins.Init[models.Plugin](root, "Plugin") {
// Register provider.
for name, provider := range plugin.Providers {
providers[name] = provider
}
}
}
func main() {
for {
answer, err := surveys.Select("Select an option", maps.Keys(interfaces.MenuOptions))
if err != nil {
log.Panicln(err)
}
if answer == "Exit" {
interfaces.MenuOptions["exit"](nil, nil)
}
ans, err := surveys.Select("Select a provider", maps.Keys(providers))
if err != nil {
log.Panicln(err)
}
interfaces.MenuOptions[answer](providers[ans], nil)
}
}