add some stubs for saving user updates to a data file

remotes/origin/persistence
Adam Veldhousen 2019-11-18 00:48:06 -06:00
parent 4e74fd955b
commit 15667ca704
Signed by: adam
GPG Key ID: 6DB29003C6DD1E4B
3 changed files with 19 additions and 4 deletions

1
.gitignore vendored
View File

@ -1,2 +1,3 @@
.bin .bin
.vscode .vscode
riffraff

View File

@ -7,9 +7,11 @@ import (
type Config struct { type Config struct {
ListenAddress string `json:"listenAddress"` ListenAddress string `json:"listenAddress"`
Shortcuts map[string]string `json:"shortcuts"` DataPath string `json:"dataPath"`
Shortcuts Shortcuts `json:"shortcuts"`
} }
func LoadShortcutsFromConfig(configPath string) (Config, error) {
func LoadConfig(configPath string) (Config, error) {
var configuration Config var configuration Config
file, err := os.Open(configPath) file, err := os.Open(configPath)
if err != nil { if err != nil {
@ -39,6 +41,18 @@ func LoadShortcutsFromConfig(configPath string) (Config, error) {
configuration.ListenAddress = "127.0.0.1" configuration.ListenAddress = "127.0.0.1"
} }
if configuration.DataPath == "" {
configuration.DataPath = "."
}
return configuration, nil return configuration, nil
} }
func SaveShortcuts(path string, shorts Shortcuts) error {
return nil
}
func LoadShortcuts(path string) (Shortcuts, error) {
return nil, nil
}

View File

@ -19,7 +19,7 @@ func main() {
box := packr.NewBox("./internal/templates") box := packr.NewBox("./internal/templates")
tp := internal.TemplateRenderer{FS: box} tp := internal.TemplateRenderer{FS: box}
config, err := internal.LoadShortcutsFromConfig(*cfgPath) config, err := internal.LoadConfig(*cfgPath)
if err != nil { if err != nil {
log.Fatalf("could not load config from file: %v", err) log.Fatalf("could not load config from file: %v", err)
} }