Skip to content

Commit

Permalink
clean
Browse files Browse the repository at this point in the history
  • Loading branch information
arrow2nd committed Dec 19, 2021
1 parent fb477d3 commit a4f4f52
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 12 deletions.
4 changes: 1 addition & 3 deletions cmd/config_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
1 change: 1 addition & 0 deletions cmd/constants.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
package cmd

// Version バージョン
const Version = "1.0.0"
16 changes: 7 additions & 9 deletions cmd/get.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,30 +24,28 @@ 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 {
return err
}

fmt.Println(results[0].TranslatedText)

return nil
}

0 comments on commit a4f4f52

Please sign in to comment.