-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
47 lines (41 loc) · 1003 Bytes
/
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
package main
import (
"fmt"
"github.com/jessevdk/go-flags"
"github.com/threft/threft-gen-html/htmlg"
"github.com/threft/threft/tidm"
"os"
)
var options struct {
Debugging bool `short:"d" long:"debug" description:"Enable logging of debug messages to StdOut"`
}
func main() {
args, err := flags.Parse(&options)
if err != nil {
flagError := err.(*flags.Error)
if flagError.Type == flags.ErrHelp {
fmt.Println("Example: threft-gen-go -p json -p binary")
fmt.Println()
return
}
if flagError.Type == flags.ErrUnknownFlag {
fmt.Println("Use --help to view all available options.")
return
}
fmt.Printf("Error parsing flags: %s\n", err)
return
}
if len(args) > 0 {
fmt.Printf("Unknown argument '%s'.", args[0])
return
}
if options.Debugging {
fmt.Println("threft-gen-html started, reading TIDM from stdin.")
}
t, err := tidm.DecodeFrom(os.Stdin)
if err != nil {
fmt.Printf("Error reading TIDM from stdin: %s\n", err)
return
}
htmlg.GenerateHtml(t)
}