Mercurial > mercurial > hgweb_golang.cgi
comparison src/gogemo/main.go @ 29:0f05c342fde1
gogemo v1.2 ( compress by bzip2 & English dictionary )
author | pyon@macmini |
---|---|
date | Sat, 23 Feb 2019 15:53:53 +0900 |
parents | 8e3f320396b8 |
children | a273d4792e48 |
comparison
equal
deleted
inserted
replaced
28:8e3f320396b8 | 29:0f05c342fde1 |
---|---|
1 /* | 1 /* |
2 Gogemo: Command-line Migemo program by go. | 2 Gogemo: Command-line Migemo program by go. |
3 Last Change: 2019-02-09 Sat 15:46:37. | 3 Last Change: 2019-02-23 Sat 15:43:49. |
4 | 4 |
5 Written by T.Mutoh | 5 Written by T.Mutoh |
6 */ | 6 */ |
7 package main | 7 package main |
8 | 8 |
12 "os" | 12 "os" |
13 | 13 |
14 "./gogemo" | 14 "./gogemo" |
15 ) | 15 ) |
16 | 16 |
17 const ver string = "1.1" | 17 const ver string = "1.2" |
18 | 18 |
19 func main() { | 19 func main() { |
20 inv := flag.Bool("v", false, "inverse (not implement)") | 20 inv := flag.Bool("v", false, "inverse (not implement)") |
21 wfn := flag.Bool("f", false, "with filename") | 21 wfn := flag.Bool("f", false, "print with filename") |
22 look := flag.Bool("l", false, "lookup dictionary") | 22 look := flag.Bool("l", false, "lookup dictionary") |
23 dout := flag.Bool("d", false, "dump dictionary (all words)") | |
23 // cnt := flag.Bool("c", false, "count matched") | 24 // cnt := flag.Bool("c", false, "count matched") |
24 // iu := flag.Bool("w", false, "input encoding: utf-8") | 25 // iu := flag.Bool("w", false, "input encoding: utf-8") |
25 // ou := flag.Bool("W", false, "output encoding: utf-8") | 26 // ou := flag.Bool("W", false, "output encoding: utf-8") |
26 // is := flag.Bool("s", false, "output encoding: shift-jis") | 27 // is := flag.Bool("s", false, "output encoding: shift-jis") |
27 // os := flag.Bool("S", false, "output encoding: shift-jis") | 28 // os := flag.Bool("S", false, "output encoding: shift-jis") |
30 var g gogemo.Gogemo | 31 var g gogemo.Gogemo |
31 g.SetOptions(*inv, *wfn) | 32 g.SetOptions(*inv, *wfn) |
32 | 33 |
33 switch flag.NArg() { | 34 switch flag.NArg() { |
34 case 0: | 35 case 0: |
35 fmt.Fprint(os.Stderr, "[ gogemo v" + ver + " ]\n") | 36 if *dout { |
36 flag.PrintDefaults() | 37 g.PrintDictionary() |
37 fmt.Fprint(os.Stderr, "\n") | 38 os.Exit(0) |
38 fmt.Fprint(os.Stderr, "> gogemo roma file1 file2...\n") | 39 } |
39 fmt.Fprint(os.Stderr, "> cat file | gogemo roma\n") | 40 print_help() |
40 fmt.Fprint(os.Stderr, "> gogemo -l roma\n") | |
41 os.Exit(0) | 41 os.Exit(0) |
42 case 1: // from stdin or look dict | 42 case 1: // from stdin or look dict |
43 g.Prepare(flag.Arg(0), nil) | 43 g.Prepare(flag.Arg(0), nil) |
44 if *look { | 44 if *look { |
45 g.Look() | 45 g.Look() |
50 } | 50 } |
51 | 51 |
52 g.Search() | 52 g.Search() |
53 } | 53 } |
54 | 54 |
55 func print_help() { | |
56 fmt.Fprint(os.Stderr, "[ gogemo v" + ver + " ]\n") | |
57 flag.PrintDefaults() | |
58 fmt.Fprint(os.Stderr, "\n") | |
59 fmt.Fprint(os.Stderr, " $ gogemo roma file\n") | |
60 fmt.Fprint(os.Stderr, " $ cat file1 file2 | gogemo roma\n") | |
61 fmt.Fprint(os.Stderr, " $ gogemo -f roma file1 file2...\n") | |
62 fmt.Fprint(os.Stderr, " $ gogemo -l roma\n") | |
63 fmt.Fprint(os.Stderr, " $ gogemo -d > dict.csv\n") | |
64 } | |
65 |