-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.go
56 lines (47 loc) · 1.01 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
package main
import (
"flag"
"fmt"
"os"
"strings"
"github.com/mbStavola/slydes/pkg/lang"
"github.com/mbStavola/slydes/render/html"
)
func main() {
filename := flag.String("file", "", "slide to open")
output := flag.String("out", "noop", "method of display (noop, html)")
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" && *output != "noop" {
fmt.Print("Output must be either noop 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 "noop":
case "html":
if err := html.Render(show); err != nil {
fmt.Print(err)
}
}
}