diff --git a/cmd/random.go b/cmd/random.go index c1c1732..e627303 100644 --- a/cmd/random.go +++ b/cmd/random.go @@ -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 }}", } diff --git a/cmd/search.go b/cmd/search.go index eb7b308..538d442 100644 --- a/cmd/search.go +++ b/cmd/search.go @@ -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() } diff --git a/cmd/version.go b/cmd/version.go new file mode 100644 index 0000000..8ac58a5 --- /dev/null +++ b/cmd/version.go @@ -0,0 +1,37 @@ +/* +Copyright © 2021 Parth S + +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) +}