forked from mbStavola/Slydes
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
63 lines (53 loc) · 1.12 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
package main
import (
"flag"
"fmt"
"github.com/mbStavola/slydes/pkg/lang"
"github.com/mbStavola/slydes/render/html"
"github.com/mbStavola/slydes/render/native"
"os"
"strings"
)
func main() {
filename := flag.String("file", "", "slide to open")
output := flag.String("out", "html", "method of display (html, native)")
debug := flag.Bool("debug", false, "print debug info")
flag.Parse()
if *filename == "" {
fmt.Print("Filename must be provided")
return
} else if !strings.HasSuffix(*filename, ".sly") {
fmt.Print("Only .sly files are supported")
return
} else if *output != "native" && *output != "html" {
fmt.Print("Output must be either native or html")
return
}
file, err := os.Open(*filename)
if err != nil {
fmt.Print(err)
return
}
defer file.Close()
sly := lang.NewSly()
if *debug {
sly = debugSly(sly)
}
show, err := sly.ReadSlideShow(file)
if err != nil {
fmt.Print(err)
return
}
switch *output {
case "native":
if err := native.Render(show); err != nil {
fmt.Print(err)
}
break
case "html":
if err := html.Render(show); err != nil {
fmt.Print(err)
}
break
}
}