add a dialog box

This commit is contained in:
idk
2022-09-29 15:56:20 -04:00
parent a2a542997f
commit 078af61777

17
main.go
View File

@ -25,6 +25,16 @@ func dialogMessage() string {
return "Enter some letters and numbers. Every visitor to your I2P tunnel will receive the same letters and numbers."
}
func copyTitle() string {
//TODO internationalize
return "Share a string"
}
func copyMessage() string {
//TODO internationalize
return "Copy the URL below to share it with others"
}
func help() string {
formattedString := fmt.Sprintf("%s\n", " -file string")
formattedString += fmt.Sprintf("%s\n", " Serve a single file after loading it from the disk")
@ -74,8 +84,10 @@ func main() {
printUsage()
log.Fatal("Serve only a string or a file, not both")
}
var got string
var ok bool
if *serveFile == "" && *serveString == "" {
got, ok := inputbox.InputBox(dialogTitle(), dialogMessage(), "")
got, ok = inputbox.InputBox(dialogTitle(), dialogMessage(), "")
if ok {
*serveString = got
}
@ -94,6 +106,9 @@ func main() {
}
log.Println("Share the following URL:")
fmt.Printf("\t%s%s\n", "http://", ln.Addr().String())
if ok {
_, _ = inputbox.InputBox(copyTitle(), copyMessage(), ln.Addr().String())
}
defer ln.Close()
if *serveString != "" {
bytes := []byte(*serveString)