Add fallback value and just show translation output

Signed-off-by: Izuru Yakumo <yakumo.izuru@chaotic.ninja>

git-svn-id: file:///srv/svn/repo/suwako/trunk@16 0b558ee1-521d-8b46-a41b-40029c97c055
This commit is contained in:
yakumo.izuru 2023-04-16 02:15:45 +00:00
parent e5f73bfde0
commit ac0db74f9b

View File

@ -1,4 +1,4 @@
// $TheSupernovaDuo: suwako,v 1.5.0 2023/03/25 10:41:00 akoizumi Exp
// $TheSupernovaDuo: suwako,v 1.5.1 2023/4/15 23:9:28 yakumo_izuru Exp $
// Command line client for SimplyTranslate, a privacy friendly frontend to other translation engines
package main
@ -38,7 +38,10 @@ func main() {
flag.Parse()
if len(engine) == 0 || len(instance) == 0 {
log.Fatal("SUWAKO_ENGINE and/or SUWAKO_INSTANCE are unset")
log.Println("SUWAKO_ENGINE and/or SUWAKO_INSTANCE are unset")
log.Println("Defaulting to translate.chaotic.ninja with engine 'google'")
engine = "google"
instance = "https://translate.chaotic.ninja"
}
if len(input) == 0 {
log.Fatal("Missing input text.")
@ -56,9 +59,7 @@ func main() {
// JSON decoding
_ = json.NewDecoder(resp.Body).Decode(&translate)
sanityCheck(err)
// Pretty-print both the input and the output given.
fmt.Printf("Input: %v\n", input)
fmt.Printf("Output: %v\n",translate.Output)
fmt.Printf("%v\n",translate.Output)
}
func sanityCheck(err error) {
if err != nil {