blob: bfb56b845d4e90cc36f0a0a4368237f176515ed1 (
plain)
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
59
60
61
62
63
64
65
66
67
68
69
70
|
package main
import (
"fmt"
"io/ioutil"
"log"
"os"
"github.com/teddywing/timetasker/timetask"
"github.com/BurntSushi/toml"
"gopkg.in/yaml.v2"
)
// type Config struct {
// Auth struct {
// Username string
// PasswordCmd string `yaml:"password_cmd"`
// }
// Fields timetask.Fields
// Defaults timetask.TimeEntry
// }
type Config struct {
Auth struct {
Username string
PasswordCmd string //`toml:"password_cmd"`
}
Projects map[string]interface{}
}
var config Config
func main() {
loadConfig()
log.Printf("%+v", config)
return
if len(os.Args) == 1 {
fmt.Println("Not enough arguments")
os.Exit(1)
}
file_path := os.Args[len(os.Args)-1]
file, err := ioutil.ReadFile(file_path)
if err != nil {
log.Println(err)
}
time_entries := []timetask.TimeEntry{}
err = yaml.Unmarshal(file, &time_entries)
if err != nil {
log.Println(err)
}
log.Printf("%+v", time_entries)
// timetask.SubmitTimeEntries(config.Fields, time_entries)
// timetask.GenerateWeeklyTimesheet(os.Stdout, config.Defaults)
}
func loadConfig() {
// config_str, err := ioutil.ReadFile("config2.toml")
config = Config{}
_, err := toml.DecodeFile("config2.toml", &config)
if err != nil {
log.Println(err)
}
}
|