Files
Jonathan Ingram 93312f47fc v2: initial commit (#153)
- Some methods have been changed to return an error as their last
  argument
- Log calls inside various functions have been removed
- Use a v1 tag if you need the previous signature
2023-10-31 11:32:40 +11:00

44 lines
777 B
Go

package main
import (
"encoding/json"
"flag"
"fmt"
"os"
"code.sajari.com/docconv/v2/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)
}
}