Skip to content

Commit

Permalink
feat(cli): added -i flag to search command
Browse files Browse the repository at this point in the history
  • Loading branch information
Nickersoft committed Jan 11, 2021
1 parent 22d2549 commit c08aebc
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
12 changes: 10 additions & 2 deletions cli/odict.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,16 @@ func main() {
{
Name: "search",
Aliases: []string{"s"},
Usage: "search a compiled dictionary",
Action: search,
Flags: []cli.Flag{
&cli.BoolFlag{
Name: "index",
Aliases: []string{"i"},
Usage: "Forcibly creates a new index if one already exists",
Value: false,
},
},
Usage: "search a compiled dictionary",
Action: search,
},
{
Name: "dump",
Expand Down
3 changes: 2 additions & 1 deletion cli/search.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
func search(c *cli.Context) error {
inputFile := c.Args().Get(0)
searchTerm := c.Args().Get(1)
force := c.Bool("index")

if len(inputFile) == 0 || len(searchTerm) == 0 {
return errors.New("Usage: odict search [odict file] [search term]")
Expand All @@ -20,7 +21,7 @@ func search(c *cli.Context) error {
t(func() {
dict := odict.ReadDictionary(inputFile)

odict.IndexDictionary(dict, false)
odict.IndexDictionary(dict, force)

results := odict.SearchDictionary(dict, searchTerm)

Expand Down

0 comments on commit c08aebc

Please sign in to comment.