diff --git a/cmd/config_api.go b/cmd/config_api.go index 8689688..d45a57a 100644 --- a/cmd/config_api.go +++ b/cmd/config_api.go @@ -10,14 +10,12 @@ import ( ) func (c *Cmd) newConfigAPICmd() *cobra.Command { - apiCmd := &cobra.Command{ + return &cobra.Command{ Use: "api", Short: "Register your API key", Args: cobra.NoArgs, RunE: c.execConfigAPICmd, } - - return apiCmd } func (c *Cmd) execConfigAPICmd(cmd *cobra.Command, args []string) error { diff --git a/cmd/constants.go b/cmd/constants.go index 0181e57..3d7e648 100644 --- a/cmd/constants.go +++ b/cmd/constants.go @@ -1,3 +1,4 @@ package cmd +// Version バージョン const Version = "1.0.0" diff --git a/cmd/get.go b/cmd/get.go index db4b0eb..50aee51 100644 --- a/cmd/get.go +++ b/cmd/get.go @@ -24,23 +24,22 @@ func (c *Cmd) newGetCmd() *cobra.Command { } func (c *Cmd) execGetCmd(cmd *cobra.Command, args []string) error { - text := args[0] - caseType, _ := cmd.Flags().GetString("case") - prefixStyle, _ := cmd.Flags().GetString("prefix") - - caseType, err := caseList.GetValue(caseType) + caseName, _ := cmd.Flags().GetString("case") + caseValue, err := caseList.GetValue(caseName) if err != nil { return fmt.Errorf("case type is wrong, please specify one of [%s]", caseList.GetListItemsString()) } - prefixStyle, err = prefixList.GetValue(prefixStyle) + prefixName, _ := cmd.Flags().GetString("prefix") + prefixValue, err := prefixList.GetValue(prefixName) if err != nil { return fmt.Errorf("prefix style is wrong, please specify one of [%s]", prefixList.GetListItemsString()) } + text := args[0] v := godic.CreateTranslateParam(text) - v.Add("casing", caseType) - v.Add("acronym_style", prefixStyle) + v.Add("casing", caseValue) + v.Add("acronym_style", prefixValue) results, err := c.api.GetTranslate(v) if err != nil { @@ -48,6 +47,5 @@ func (c *Cmd) execGetCmd(cmd *cobra.Command, args []string) error { } fmt.Println(results[0].TranslatedText) - return nil }