aboutsummaryrefslogtreecommitdiff
path: root/cmd/dict/main.go
blob: 9dc98cf58caa9536b14854fde509d3d164e82e11 (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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
package main

import (
	"fmt"
	"log/slog"
	"os"
	"path/filepath"

	"github.com/urfave/cli/v2"

	"git.gabrielgio.me/dict/cmd/importer"
	"git.gabrielgio.me/dict/cmd/server"
	"git.gabrielgio.me/dict/cmd/ui"
	"git.gabrielgio.me/dict/db"
)

var Version = "local"

func main() {
	app := &cli.App{
		Name:  "dict",
		Usage: "interactive dictionary",
		Commands: []*cli.Command{
			importer.ImportCommand,
			ui.UICommand,
			server.ServeCommand,
			{
				Name:  "version",
				Usage: "print current version",
				Flags: []cli.Flag{},
				Action: func(cCtx *cli.Context) error {
					fmt.Printf("%s - %s\n\n", filepath.Base(os.Args[0]), Version)
					fmt.Printf("Spellfix locaton: %s.so", db.LibPath)
					return nil
				},
			},
		},
	}

	if err := app.Run(os.Args); err != nil {
		slog.Error("Error running application", "error", err)
		os.Exit(1)
	}
}