-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsimpledict.go
More file actions
46 lines (39 loc) · 814 Bytes
/
simpledict.go
File metadata and controls
46 lines (39 loc) · 814 Bytes
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
45
46
package main
import (
"simpledict/dict"
"github.com/fatih/color"
)
func getAllDicts() *[]dict.Dict {
return &[]dict.Dict{
dict.NewCambridge(),
dict.NewFreeDictionary(),
dict.NewVocabulary(),
}
}
func runDict(word *string, d *dict.Dict) (*dict.Result, error) {
return (*d).GetDefinition(word)
}
func printResult(r *dict.Result, syn *bool) {
{
c := color.New(color.BgHiMagenta, color.Underline)
c.Println("Definitions :")
c = color.New(color.FgHiMagenta)
for _, d := range r.Definition {
if d == "" {
continue
}
c.Printf("> %s\n", d)
}
}
if *syn {
c := color.New(color.BgHiCyan, color.FgBlack, color.Underline)
c.Println("Synonyms :")
c = color.New(color.FgHiCyan)
for _, s := range r.Synonyms {
if s == "" {
continue
}
c.Printf("- %s\n", s)
}
}
}