add a dialog box
This commit is contained in:
17
main.go
17
main.go
@ -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)
|
||||
|
Reference in New Issue
Block a user