forked from aksdb/CalAnonSync
Externalized settings
This commit is contained in:
parent
678578dcac
commit
20a1ebbf1f
|
@ -151,7 +151,9 @@ func (e *EWSCalendar) getCalendarItems(folder *FolderId, start, end time.Time) (
|
|||
}
|
||||
|
||||
func main() {
|
||||
e := NewEWSCalendar("https://outlook.live.com/EWS/Exchange.asmx", "", "")
|
||||
s := LoadSettings()
|
||||
|
||||
e := NewEWSCalendar(s.EWS.URL, s.EWS.Username, s.EWS.Password)
|
||||
id, err := e.getCalendarFolderID()
|
||||
if err != nil {
|
||||
log.Println(err)
|
||||
|
|
|
@ -0,0 +1,33 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"os"
|
||||
)
|
||||
|
||||
type ServerSettings struct {
|
||||
URL string
|
||||
Username string
|
||||
Password string
|
||||
}
|
||||
|
||||
type Settings struct {
|
||||
EWS ServerSettings
|
||||
CalDAV ServerSettings
|
||||
Anonymize struct {
|
||||
Title string
|
||||
}
|
||||
}
|
||||
|
||||
func LoadSettings() Settings {
|
||||
f, err := os.Open("calanonsync.json")
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
settings := Settings{}
|
||||
err = json.NewDecoder(f).Decode(&settings)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return settings
|
||||
}
|
Loading…
Reference in New Issue