mozhi/cmd/translate.go

45 lines
1.7 KiB
Go
Raw Normal View History

2023-06-24 18:40:57 +00:00
package cmd
import (
"codeberg.org/aryak/mozhi/utils"
2023-07-03 11:59:46 +00:00
"fmt"
2023-07-22 14:24:15 +00:00
"github.com/spf13/cobra"
2023-06-24 18:40:57 +00:00
)
var engine string
var query string
var source string
var dest string
var langlist string
var translateCmd = &cobra.Command{
Use: "translate",
Short: "Translate.",
Long: `Translate.`,
Run: func(cmd *cobra.Command, args []string) {
if langlist == "sl" || langlist == "tl" {
fmt.Println(utils.LangList(engine, langlist))
} else if engine == "all"{
2023-06-24 18:40:57 +00:00
fmt.Println(utils.TranslateAll(dest, source, query))
} else {
fmt.Println(utils.Translate(engine, dest, source, query))
2023-06-24 18:40:57 +00:00
}
},
}
func init() {
rootCmd.AddCommand(translateCmd)
translateCmd.Flags().StringVarP(&engine, "engine", "e", "", "The source Mozhi will listen to. Defaults to 3000, and overrides the MOZHI_source environment variable.")
translateCmd.Flags().StringVarP(&source, "source", "s", "", "The source Mozhi will listen to. Defaults to 3000, and overrides the MOZHI_source environment variable.")
translateCmd.Flags().StringVarP(&dest, "dest", "t", "", "The dest Mozhi will listen to. Defaults to 3000, and overrides the MOZHI_dest environment variable.")
translateCmd.Flags().StringVarP(&query, "query", "q", "", "The query Mozhi will listen to. Defaults to 3000, and overrides the MOZHI_query environment variable.")
translateCmd.Flags().StringVarP(&langlist, "langlist", "l", "", "The query Mozhi will listen to. Defaults to 3000, and overrides the MOZHI_query environment variable.")
2023-06-24 18:40:57 +00:00
engine = translateCmd.Flag("engine").Value.String()
dest = translateCmd.Flag("dest").Value.String()
source = translateCmd.Flag("source").Value.String()
query = translateCmd.Flag("query").Value.String()
langlist = translateCmd.Flag("query").Value.String()
}