Skip to content

Commit

Permalink
Fix translate command
Browse files Browse the repository at this point in the history
  • Loading branch information
cluttrdev committed Feb 19, 2023
1 parent e7cf9f3 commit a87df3e
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions pkg/cmd/translate.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"fmt"
"log"

"github.com/pkg/errors"
"github.com/spf13/cobra"
"github.com/spf13/pflag"

Expand Down Expand Up @@ -39,6 +40,10 @@ var translateCmd = &cobra.Command{
opt deepl.TranslateOption
)

if flag.Name == "target-lang" {
return
}

if flag.Changed {
switch flag.Name {
case "source-lang":
Expand All @@ -61,6 +66,9 @@ var translateCmd = &cobra.Command{
opt, err = deepl.SplittingTags(flag.Value.String())
case "ignore-tags":
opt, err = deepl.IgnoreTags(flag.Value.String())

default:
opt, err = nil, errors.Errorf("Invalid option: %s", flag.Name)
}

if err != nil {
Expand All @@ -81,9 +89,8 @@ var translateCmd = &cobra.Command{
for _, translation := range translations {
if v, _ := cmd.Flags().GetCount("verbose"); v > 0 {
fmt.Printf("Detected Source Language: %s\n", translation.DetectedSourceLanguage)
} else {
fmt.Println(translation.Text)
}
fmt.Println(translation.Text)
}
},
}
Expand Down

0 comments on commit a87df3e

Please sign in to comment.