-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
43 lines (35 loc) · 781 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
package main
import (
"encoding/json"
"flag"
"fmt"
"os"
"github.com/danangsigit/docconv/client"
)
var (
path = flag.String("path", "", "`path` to file to convert")
endpoint = flag.String("endpoint", "", "docconv HTTP server to use for conversion")
)
func main() {
flag.Parse()
if *path == "" {
fmt.Println("must set -path")
os.Exit(1)
}
var opts []client.Opt
if *endpoint != "" {
opts = append(opts, client.WithEndpoint(*endpoint))
}
c := client.New(opts...)
resp, err := client.ConvertPath(c, *path)
if err != nil {
fmt.Printf("Could not convert: %v", err)
os.Exit(1)
}
enc := json.NewEncoder(os.Stdout)
enc.SetIndent("", " ")
if err := enc.Encode(resp); err != nil {
fmt.Printf("Could not encode response: %v", err)
os.Exit(1)
}
}