-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
80 lines (63 loc) · 1.34 KB
/
main.go
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
71
72
73
74
75
76
77
78
79
80
package main
import (
"fmt"
"github.com/EzxD/Leibniz-FH-TimeTable/cal"
"github.com/EzxD/Leibniz-FH-TimeTable/xlsx"
"github.com/manifoldco/promptui"
"github.com/xuri/excelize/v2"
)
func main() {
prompt := promptui.Prompt{
Label: "Calendar ID",
Default: "primary",
}
calID, err := prompt.Run()
cal.CalendarId = calID
if err != nil {
fmt.Printf("Prompt failed %v\n", err)
return
}
timetableName := promptui.Prompt{
Label: "xlsx file name",
Default: "plan.xlsx",
}
tableName, err := timetableName.Run()
xlsx.UnmergeAllCells(tableName)
//fmt.Printf("Your username is %q\n", result)
promptSelect := promptui.Select{
Label: "What do you want to do?",
Items: []string{"Create", "Delete"},
}
_, result, err := promptSelect.Run()
if err != nil {
fmt.Printf("Prompt failed %v\n", err)
return
}
fmt.Printf("You choose %q\n", result)
if result == "Create" {
createAll()
}
if result == "Delete" {
cal.DeleteAllUniEvents()
}
}
func createAll() {
f, err := excelize.OpenFile("unmerged.xlsx")
if err != nil {
fmt.Println(err)
return
}
defer func() {
// Close the spreadsheet.
if err := f.Close(); err != nil {
fmt.Println(err)
}
}()
kws, err := xlsx.GetAllWeeks(f)
if err != nil {
fmt.Printf("failed to parse all weeks %v\n", err)
}
for k, v := range kws {
xlsx.AddWeekToCal(k, v, f)
}
}