Skip to content

Commit

Permalink
fix bug for no example in API, added version cmd
Browse files Browse the repository at this point in the history
  • Loading branch information
Parth576 committed Mar 19, 2021
1 parent a6f6eca commit d9d70aa
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 4 deletions.
2 changes: 1 addition & 1 deletion cmd/random.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ var randomCmd = &cobra.Command{
Label: "{{ . }}",
Active: "\u279C {{ .Word | yellow }}",
Inactive: "{{ .Word | yellow }}",
Selected: "Thanks for using gowords!",
Selected: " ",
Details: "\n{{ .Content }}",
}

Expand Down
8 changes: 5 additions & 3 deletions cmd/search.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,11 +92,13 @@ func searchInDict(word string) {
//fmt.Printf("%s\n\n", defs[key].([]interface{})[0].(map[string]interface{})["definition"])
for _, j := range defs[key].([]interface{}) {
defTemp := j.(map[string]interface{})["definition"]
example := j.(map[string]interface{})["example"]
example, exampleExists := j.(map[string]interface{})["example"]
fmt.Printf("%s\u279C%s%s%s\n", colors.Blue, " ", colors.Reset, defTemp)
fmt.Printf("%s\u2605%s%s%s\n", colors.Yellow, " ", colors.Reset, example)
cacheSave[pos] = append(cacheSave[pos], defTemp)
cacheSave[pos] = append(cacheSave[pos], "68f3fde1-8c1a-49eb-9f27-8d951b049142"+example.(string))
if exampleExists {
fmt.Printf("%s\u2605%s%s%s\n", colors.Yellow, " ", colors.Reset, example)
cacheSave[pos] = append(cacheSave[pos], "68f3fde1-8c1a-49eb-9f27-8d951b049142"+example.(string))
}
}
fmt.Println()
}
Expand Down
37 changes: 37 additions & 0 deletions cmd/version.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/*
Copyright © 2021 Parth S <[email protected]>
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package cmd

import (
"fmt"
"runtime"

"github.com/spf13/cobra"
)

var versionCmd = &cobra.Command{
Use: "version",
Short: "Get the version of gowords",
Run: func(cmd *cobra.Command, args []string) {
os := runtime.GOOS
arch := runtime.GOARCH
fmt.Printf("v0.0.6 %s/%s\n", os, arch)
},
}

func init() {
rootCmd.AddCommand(versionCmd)
}

0 comments on commit d9d70aa

Please sign in to comment.