Legend:
- Unmodified
- Added
- Removed
-
trunk/cmd/suwako/main.go
r22 r23 1 // $TheSupernovaDuo: suwako,v 1.5. 2 2023/10/21 00:58:44yakumo_izuru Exp $1 // $TheSupernovaDuo: suwako,v 1.5.3 2023/10/22 02:01:48 yakumo_izuru Exp $ 2 2 // Command line client for SimplyTranslate, a privacy friendly frontend to other translation engines 3 3 package main … … 5 5 import ( 6 6 "encoding/json" 7 "flag"8 7 "fmt" 9 8 "log" … … 12 11 "os" 13 12 13 "github.com/integrii/flaggy" 14 14 "github.com/joho/godotenv" 15 15 "marisa.chaotic.ninja/suwako" … … 20 20 instance string 21 21 input string 22 source string 22 source string = "auto" 23 23 target string 24 24 ) … … 35 35 36 36 func loadCfg() { 37 flag .StringVar(&source, "f", "auto", "Set the language to translate from. This can be skipped as it will autodetect the language you're translating from")38 flag .StringVar(&input, "i", "", "Enter the text to be translated")39 flag .StringVar(&target, "t", "", "Set the language to translate to")37 flaggy.SetName("suwako") 38 flaggy.SetDescription("Command line client for SimplyTranslate") 39 flaggy.SetVersion(suwako.FullVersion()) 40 40 41 flag .Usage = func() {42 fmt.Printf("usage: suwako -f [lang] -i [text] -t [lang]\nversion: %v\n", suwako.FullVersion())43 }41 flaggy.String(&source, "f", "from", "Source language") 42 flaggy.String(&target, "t", "to", "Target language") 43 flaggy.AddPositionalValue(&input, "input", 1, true, "Text to translate") 44 44 45 45 home, err := os.UserHomeDir() … … 52 52 instance = os.Getenv("SUWAKO_INSTANCE") 53 53 54 flag .Parse()54 flaggy.Parse() 55 55 } 56 56 … … 60 60 61 61 // Verify command-line inputs 62 if len(input) == 0 {63 log.Fatal("There is no input")64 }65 62 if len(target) == 0 { 66 63 log.Fatal("No target language") -
trunk/go.mod
r21 r23 3 3 go 1.18 4 4 5 require github.com/joho/godotenv v1.5.1 5 require ( 6 github.com/integrii/flaggy v1.5.2 7 github.com/joho/godotenv v1.5.1 8 ) -
trunk/go.sum
r21 r23 1 github.com/google/go-cmp v0.5.6 h1:BKbKCqvP6I+rmFHt06ZmyQtvB8xAkWdhFyr0ZUNZcxQ= 2 github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= 3 github.com/integrii/flaggy v1.5.2 h1:bWV20MQEngo4hWhno3i5Z9ISPxLPKj9NOGNwTWb/8IQ= 4 github.com/integrii/flaggy v1.5.2/go.mod h1:dO13u7SYuhk910nayCJ+s1DeAAGC1THCMj1uSFmwtQ8= 1 5 github.com/joho/godotenv v1.5.1 h1:7eLL/+HRGLY0ldzfGMeQkb7vMd0as4CfYvUVzLqw0N0= 2 6 github.com/joho/godotenv v1.5.1/go.mod h1:f4LDr5Voq0i2e/R5DDNOoa2zzDfwtkZa6DnEwAbqwq4= 7 golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
Note:
See TracChangeset
for help on using the changeset viewer.