Add scripts config option
This commit is contained in:
parent
2a8789762f
commit
5ef546f085
|
|
@ -10,12 +10,14 @@ import (
|
|||
type AppConfig struct {
|
||||
SyncInterval int // Sync time in minutes
|
||||
ShouldCache bool // Should we cache the rss feeds
|
||||
Scripts []string // Scripts to execute
|
||||
}
|
||||
|
||||
func createDefaultConfig(configPath string) {
|
||||
config := AppConfig{
|
||||
SyncInterval: 60,
|
||||
ShouldCache: true,
|
||||
Scripts: []string{"all"},
|
||||
}
|
||||
file, err := os.Create(configPath + "/config.toml")
|
||||
if err != nil {
|
||||
|
|
@ -33,6 +35,7 @@ func printConfig() {
|
|||
logger.Debug("Loaded config:")
|
||||
logger.Debug("Sync time: ", appConfig.SyncInterval)
|
||||
logger.Debug("Should cache: ", appConfig.ShouldCache)
|
||||
logger.Debug("Scripts: ", appConfig.Scripts)
|
||||
}
|
||||
|
||||
func loadAppConfig() {
|
||||
|
|
|
|||
26
lua.go
26
lua.go
|
|
@ -49,14 +49,24 @@ func LoadScripts(L *lua.LState) error {
|
|||
return err
|
||||
}
|
||||
|
||||
for _, file := range files {
|
||||
var extension = filepath.Ext(file.Name())
|
||||
if file.IsDir() || extension != ".lua" {
|
||||
continue
|
||||
loadAllScripts := appConfig.Scripts[0] == "all" || appConfig.Scripts[0] == ""
|
||||
if loadAllScripts {
|
||||
for _, file := range files {
|
||||
var extension = filepath.Ext(file.Name())
|
||||
if file.IsDir() || extension != ".lua" {
|
||||
continue
|
||||
}
|
||||
if err := loadScript(L, "scripts/"+file.Name()); err != nil {
|
||||
logger.Fatal(err)
|
||||
return err
|
||||
}
|
||||
}
|
||||
if err := loadScript(L, "scripts/"+file.Name()); err != nil {
|
||||
logger.Fatal(err)
|
||||
return err
|
||||
} else {
|
||||
for _, script := range appConfig.Scripts {
|
||||
if err := loadScript(L, "scripts/"+script+".lua"); err != nil {
|
||||
logger.Fatal(err)
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
return nil
|
||||
|
|
@ -172,7 +182,7 @@ func parse_xml_feed(L *lua.LState) int {
|
|||
return 1
|
||||
}
|
||||
|
||||
//TODO: Move this into the rss table
|
||||
// TODO: Move this into the rss table
|
||||
func create_rss_feed(L *lua.LState) int {
|
||||
//TODO: Check that the parameters are correct
|
||||
feed := RssRoot{}
|
||||
|
|
|
|||
Loading…
Reference in New Issue