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:
@@ -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
|
// Command line client for SimplyTranslate, a privacy friendly frontend to other translation engines
|
||||||
package main
|
package main
|
||||||
|
|
||||||
@@ -38,7 +38,10 @@ func main() {
|
|||||||
flag.Parse()
|
flag.Parse()
|
||||||
|
|
||||||
if len(engine) == 0 || len(instance) == 0 {
|
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 {
|
if len(input) == 0 {
|
||||||
log.Fatal("Missing input text.")
|
log.Fatal("Missing input text.")
|
||||||
@@ -56,9 +59,7 @@ func main() {
|
|||||||
// JSON decoding
|
// JSON decoding
|
||||||
_ = json.NewDecoder(resp.Body).Decode(&translate)
|
_ = json.NewDecoder(resp.Body).Decode(&translate)
|
||||||
sanityCheck(err)
|
sanityCheck(err)
|
||||||
// Pretty-print both the input and the output given.
|
fmt.Printf("%v\n",translate.Output)
|
||||||
fmt.Printf("Input: %v\n", input)
|
|
||||||
fmt.Printf("Output: %v\n",translate.Output)
|
|
||||||
}
|
}
|
||||||
func sanityCheck(err error) {
|
func sanityCheck(err error) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
Reference in New Issue
Block a user