summaryrefslogtreecommitdiff
path: root/cmd/hocrtotxt/main.go
blob: 6716a9e807fb616402ebadcd67aa09800d794a24 (plain)
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
package main

import (
	"flag"
	"fmt"
	"log"
	"os"

	"rescribe.xyz/utils/pkg/hocr"
)

func main() {
	flag.Usage = func() {
		fmt.Fprintf(os.Stderr, "Usage: hocrtotxt hocrfile\n")
		fmt.Fprintf(os.Stderr, "Prints the text from a hocr file.\n")
		flag.PrintDefaults()
	}
	flag.Parse()
	if flag.NArg() != 1 {
		flag.Usage()
		os.Exit(1)
	}

	text, err := hocr.GetText(flag.Arg(0))
	if err != nil {
		log.Fatal(err)
	}

	fmt.Printf("%s\n", text)
}