-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathflags.go
More file actions
39 lines (35 loc) · 676 Bytes
/
flags.go
File metadata and controls
39 lines (35 loc) · 676 Bytes
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
package cli
type Flags map[string]interface{}
// Returns boolean flag, also returns false if flag is missing
func (f Flags) Boolean(name string) bool {
if f == nil {
return false
}
val, exists := f[name]
if !exists {
return false
}
return val.(bool)
}
// Returns integer flag, also returns 0 if flag is missing
func (f Flags) Integer(name string) int {
if f == nil {
return 0
}
val, exists := f[name]
if !exists {
return 0
}
return val.(int)
}
// Returns string flag, also returns 0 if flag is missing
func (f Flags) String(name string) string {
if f == nil {
return ""
}
val, exists := f[name]
if !exists {
return ""
}
return val.(string)
}