-
Notifications
You must be signed in to change notification settings - Fork 0
/
dialogbox.go
99 lines (87 loc) · 1.96 KB
/
dialogbox.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
package main
import (
"flag"
"fmt"
"github.com/pedroalbanese/dlgs"
"log"
"os"
"time"
)
var (
date = flag.Bool("date", false, "Date selection dialog box")
erro = flag.Bool("error", false, "Error dialog box")
file = flag.Bool("file", false, "File selection dialog box")
folder = flag.Bool("folder", false, "Folder selection dialog box")
info = flag.Bool("info", false, "Info dialog box")
input = flag.Bool("input", false, "Text input box")
password = flag.Bool("pass", false, "Password input box")
question = flag.Bool("quest", false, "Question dialog box (Check the Exit code)")
subtitle = flag.String("sub", "Subtitle", "Box subtitle")
title = flag.String("title", "Title", "Box title")
)
func main() {
flag.Parse()
if len(os.Args) < 2 {
fmt.Fprintln(os.Stderr, "Usage of", os.Args[0]+":")
flag.PrintDefaults()
os.Exit(1)
}
if *info == true {
_, err := dlgs.Info(*title, *subtitle)
if err != nil {
log.Fatal(err)
}
}
if *erro == true {
_, err := dlgs.Error(*title, *subtitle)
if err != nil {
log.Fatal(err)
}
}
if *input == true {
msg, _, err := dlgs.Entry(*title, *subtitle, "")
if err != nil {
log.Fatal(err)
}
fmt.Println(msg)
}
if *password == true {
passwd, _, err := dlgs.Password(*title, *subtitle+": ")
if err != nil {
log.Fatal(err)
}
fmt.Println(passwd)
}
if *question == true {
qst, err := dlgs.Question(*title, *subtitle, true)
if err != nil {
log.Fatal(err)
}
if qst == true {
os.Exit(0)
} else {
os.Exit(1)
}
}
if *folder == true {
folder, _, err := dlgs.File("Select folder", "*", true)
if err != nil {
log.Fatal(err)
}
fmt.Println(folder)
}
if *file == true {
file, _, err := dlgs.File("Select file", "*", false)
if err != nil {
log.Fatal(err)
}
fmt.Println(file)
}
if *date == true {
dat, _, err := dlgs.Date(*title, *subtitle, time.Now())
if err != nil {
log.Fatal(err)
}
fmt.Println(dat.Format("2006-01-02"))
}
}