Mercurial > mercurial > hgweb_golang.cgi
comparison src/gogemo/main.go @ 27:3d6709f41037
gogemo.
author | pyon@macmini |
---|---|
date | Sun, 03 Feb 2019 20:31:02 +0900 |
parents | |
children | 8e3f320396b8 |
comparison
equal
deleted
inserted
replaced
26:1b293bb0a011 | 27:3d6709f41037 |
---|---|
1 /* | |
2 Gogemo: Command-line Migemo program by go. | |
3 Last Change: 2019-02-03 Sun 19:45:42. | |
4 | |
5 Written by T.Mutoh | |
6 */ | |
7 package main | |
8 | |
9 import ( | |
10 "flag" | |
11 "fmt" | |
12 "os" | |
13 | |
14 "./gogemo" | |
15 ) | |
16 | |
17 const ver string = "1.0" | |
18 | |
19 func main() { | |
20 inv := flag.Bool("v", false, "inverse") | |
21 wfn := flag.Bool("f", false, "with filename") | |
22 look := flag.Bool("l", false, "lookup dictionary") | |
23 // cnt := flag.Bool("c", false, "count matched") | |
24 // iu := flag.Bool("w", false, "input encoding: utf-8") | |
25 // ou := flag.Bool("W", false, "output encoding: utf-8") | |
26 // is := flag.Bool("s", false, "output encoding: shift-jis") | |
27 // os := flag.Bool("S", false, "output encoding: shift-jis") | |
28 flag.Parse() | |
29 | |
30 var g gogemo.Gogemo | |
31 g.SetOptions(*inv, *wfn) | |
32 | |
33 switch flag.NArg() { | |
34 case 0: | |
35 fmt.Fprint( os.Stderr, "[ gogemo v" + ver + " ]\n") | |
36 flag.PrintDefaults() | |
37 os.Exit(0) | |
38 case 1: // from stdin or look dict | |
39 g.Prepare(flag.Arg(0), nil) | |
40 if *look { | |
41 g.Look() | |
42 os.Exit(0) | |
43 } | |
44 default: | |
45 g.Prepare(flag.Arg(0), flag.Args()[1:]) | |
46 } | |
47 | |
48 g.Search() | |
49 } | |
50 |