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." 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 { func help() string {
formattedString := fmt.Sprintf("%s\n", " -file string") formattedString := fmt.Sprintf("%s\n", " -file string")
formattedString += fmt.Sprintf("%s\n", " Serve a single file after loading it from the disk") formattedString += fmt.Sprintf("%s\n", " Serve a single file after loading it from the disk")
@ -74,8 +84,10 @@ func main() {
printUsage() printUsage()
log.Fatal("Serve only a string or a file, not both") log.Fatal("Serve only a string or a file, not both")
} }
var got string
var ok bool
if *serveFile == "" && *serveString == "" { if *serveFile == "" && *serveString == "" {
got, ok := inputbox.InputBox(dialogTitle(), dialogMessage(), "") got, ok = inputbox.InputBox(dialogTitle(), dialogMessage(), "")
if ok { if ok {
*serveString = got *serveString = got
} }
@ -94,6 +106,9 @@ func main() {
} }
log.Println("Share the following URL:") log.Println("Share the following URL:")
fmt.Printf("\t%s%s\n", "http://", ln.Addr().String()) fmt.Printf("\t%s%s\n", "http://", ln.Addr().String())
if ok {
_, _ = inputbox.InputBox(copyTitle(), copyMessage(), ln.Addr().String())
}
defer ln.Close() defer ln.Close()
if *serveString != "" { if *serveString != "" {
bytes := []byte(*serveString) bytes := []byte(*serveString)