-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdrawio.go
More file actions
56 lines (46 loc) · 1.18 KB
/
drawio.go
File metadata and controls
56 lines (46 loc) · 1.18 KB
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
package main
import (
"os"
"bufio"
"fmt"
"path"
)
func check(e error) {
if e != nil { fmt.Println(e); os.Exit(1)}
}
func GenDrawioFile(a_gsi []GitStatusItem) {
folder_name, err := os.Getwd()
check(err)
fmt.Println("Generating drawio file:", folder_name+"/"+path.Base(folder_name)+".dio")
f, err := os.Create(folder_name+"/"+path.Base(folder_name)+".dio")
check(err)
defer f.Close()
w := bufio.NewWriter(f)
_, err = w.WriteString(`
<mxfile host="65bd71144e">
<diagram id="xYE1o5OOA-KSdR3Z0aG8" name="Page-1">
<mxGraphModel dx="1748" dy="975" grid="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="1169" pageHeight="827" math="0" shadow="0">
<root>
<mxCell id="0"/>
<mxCell id="1" parent="0"/>
`)
check(err)
offsetI:=2
offsetX:=10
offsetY:=30
for i, gsi := range a_gsi {
x := ((i % 7) * 170) + offsetX
y := ((i / 7) * 90) + offsetY
str := gsi.Drawio(i+offsetI, x, y)
_, err = w.WriteString(str)
check(err)
}
_, err = w.WriteString(`
</root>
</mxGraphModel>
</diagram>
</mxfile>
`)
check(err)
w.Flush()
}