Skip to content

Commit b802f44

Browse files
authored
Add RackDiag, PacketDiag, Vega, Vega-Lite and WaveDrom support (#12)
* Add RackDiag, PacketDiag, Vega, Vega-Lite and WaveDrom support Upgrade to kroki-go v0.4.0 * Update goreleaser config
1 parent 359bcf9 commit b802f44

5 files changed

Lines changed: 73 additions & 7 deletions

File tree

.goreleaser.yml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,11 @@ builds:
1717
goarch:
1818
- amd64
1919

20-
archive:
21-
format_overrides:
22-
- goos: windows
23-
format: zip
20+
archives:
21+
-
22+
format_overrides:
23+
- goos: windows
24+
format: zip
2425

2526
release:
2627
github:

cmd/convert.go

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,16 @@ func GraphFormatFromValue(value string) (kroki.DiagramType, error) {
191191
return kroki.ActDiag, nil
192192
case "ditaa":
193193
return kroki.Ditaa, nil
194+
case "rackdiag":
195+
return kroki.RackDiag, nil
196+
case "packetdiag":
197+
return kroki.PacketDiag, nil
198+
case "vega":
199+
return kroki.Vega, nil
200+
case "vegalite":
201+
return kroki.VegaLite, nil
202+
case "wavedrom":
203+
return kroki.WaveDrom, nil
194204
default:
195205
return kroki.DiagramType(""), errors.Errorf(
196206
"invalid graph format %s.",
@@ -228,6 +238,16 @@ func GraphFormatFromFile(filePath string) (kroki.DiagramType, error) {
228238
return kroki.ActDiag, nil
229239
case ".ditaa":
230240
return kroki.Ditaa, nil
241+
case ".rackdiag":
242+
return kroki.RackDiag, nil
243+
case ".packetdiag":
244+
return kroki.PacketDiag, nil
245+
case ".vega", ".vg":
246+
return kroki.Vega, nil
247+
case ".vegalite", ".vgl", ".vl":
248+
return kroki.VegaLite, nil
249+
case "wavedrom":
250+
return kroki.WaveDrom, nil
231251
default:
232252
return kroki.DiagramType(""), errors.Errorf(
233253
"unable to infer the graph format from the file extension %s, please specify the diagram type using --type flag.",

cmd/convert_test.go

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,49 @@ func TestResolveOutputFilePath(t *testing.T) {
5959
}
6060
}
6161

62+
func TestGraphFormatFromFile(t *testing.T) {
63+
cases := []struct {
64+
filePath string
65+
expected kroki.DiagramType
66+
}{
67+
{
68+
filePath: "/path/to/hello.dot",
69+
expected: kroki.GraphViz,
70+
},
71+
{
72+
filePath: "/path/to/hello.puml",
73+
expected: kroki.PlantUML,
74+
},
75+
{
76+
filePath: "/path/to/hello.plantuml",
77+
expected: kroki.PlantUML,
78+
},
79+
{
80+
filePath: "/path/to/hello.vega",
81+
expected: kroki.Vega,
82+
},
83+
{
84+
filePath: "/path/to/hello.vg",
85+
expected: kroki.Vega,
86+
},
87+
{
88+
filePath: "hello.vl",
89+
expected: kroki.VegaLite,
90+
},
91+
{
92+
filePath: "hello.c4",
93+
expected: kroki.C4PlantUML,
94+
},
95+
}
96+
for _, c := range cases {
97+
98+
result, _ := GraphFormatFromFile(c.filePath)
99+
if result != c.expected {
100+
t.Errorf("GraphFormatFromFile error\nexpected: %s\nactual: %s", c.expected, result)
101+
}
102+
}
103+
}
104+
62105
func TestResolveImageFormat(t *testing.T) {
63106
cases := []struct {
64107
imageFormatRaw string

go.mod

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
module kroki
22

3+
go 1.14
4+
35
require (
46
github.com/inconshreveable/mousetrap v1.0.0 // indirect
57
github.com/pkg/errors v0.8.1
68
github.com/spf13/cobra v0.0.3
79
github.com/spf13/viper v1.3.1
8-
github.com/yuzutech/kroki-go v0.3.0
10+
github.com/yuzutech/kroki-go v0.4.0
911
)

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,12 @@ github.com/ugorji/go/codec v0.0.0-20181204163529-d75b2dcb6bc8/go.mod h1:VFNgLljT
3535
github.com/xordataexchange/crypt v0.0.3-0.20170626215501-b2862e3d0a77/go.mod h1:aYKd//L2LvnjZzWKhF00oedf4jCCReLcmhLdhm1A27Q=
3636
github.com/yuzutech/kroki-go v0.1.0 h1:fuQTmYDpZM1LMIxp9NVuL69a823aef9lAuCQ17IUkpU=
3737
github.com/yuzutech/kroki-go v0.1.0/go.mod h1:75GoPIdAFlGbVkHdyNhF5qHlf3uT0jWpBIFuCVz8omY=
38-
github.com/yuzutech/kroki-go v0.1.1-0.20190219183547-bfe91c3e23c2 h1:1Vzhq5g76xAazH/2CSoE7GfVxSl28/+9rnkqMA8VqsQ=
39-
github.com/yuzutech/kroki-go v0.1.1-0.20190219183547-bfe91c3e23c2/go.mod h1:Cys0gjXdlViePdrZ4AKMUyX4yVIAoIhMBhvpYPJahrk=
4038
github.com/yuzutech/kroki-go v0.2.0 h1:BZ7CMkepyJ4JGUrO43GRRKTCMnAOc0eFceZBrPm6zuQ=
4139
github.com/yuzutech/kroki-go v0.2.0/go.mod h1:Cys0gjXdlViePdrZ4AKMUyX4yVIAoIhMBhvpYPJahrk=
4240
github.com/yuzutech/kroki-go v0.3.0 h1:GIQv3jVQF8GNl6k+el55pksFeV7mJ9dQr9wPjyNj6nI=
4341
github.com/yuzutech/kroki-go v0.3.0/go.mod h1:Cys0gjXdlViePdrZ4AKMUyX4yVIAoIhMBhvpYPJahrk=
42+
github.com/yuzutech/kroki-go v0.4.0 h1:2w2Vxd7yleXB29vZUL7UVZ2RFL3UfTgYwd4I6poNMIM=
43+
github.com/yuzutech/kroki-go v0.4.0/go.mod h1:Cys0gjXdlViePdrZ4AKMUyX4yVIAoIhMBhvpYPJahrk=
4444
golang.org/x/crypto v0.0.0-20181203042331-505ab145d0a9/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
4545
golang.org/x/sys v0.0.0-20181205085412-a5c9d58dba9a h1:1n5lsVfiQW3yfsRGu98756EH1YthsFqr/5mxHduZW2A=
4646
golang.org/x/sys v0.0.0-20181205085412-a5c9d58dba9a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=

0 commit comments

Comments
 (0)