~kris/9p

glenda

ref: 2e156f53f7feae892a718d97d1c28ac967be109e glenda/config.go -rw-r--r-- 974 bytes
2e156f53 — Sean Hinchee cleaning 8 years ago
                                                                                
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

// General configuration utilities for Glenda

import (
	"encoding/json"
	"os"
	"fmt"
)

// Stores config for current state
type Configuration struct {
	LastChange string
}

// Initializes current config (called once at start)
func (c *Configuration) Init() {
}

// Writes current config
func (c *Configuration) Write() (rerr error) {
	rerr = nil
	f, err := os.Open("./cfg/glenda.cfg")
	defer f.Close()
	if err != nil {
		fmt.Println("Error opening config, see: config.go")
		fmt.Printf("%s\n", err)
		rerr = err
	}

	e := json.NewEncoder(f)
	err = e.Encode(Config)
	if err != nil {
		fmt.Println("Error writing config, see: config.go")
		fmt.Printf("%s\n", err)
		rerr = err
	}
	return
}

// Reads current config into memory
func (c *Configuration) Read() {

}

// Set up config for the first time (if one doesn't exist)
func (c *Configuration) Setup() {
	// Test/make cfg folder


	// Test/make cfg


}

// Global variables are bad
var Config Configuration