-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathutils.go
More file actions
52 lines (43 loc) · 981 Bytes
/
utils.go
File metadata and controls
52 lines (43 loc) · 981 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
40
41
42
43
44
45
46
47
48
49
50
51
52
package parser
import (
"fmt"
"log"
"strconv"
"github.com/deis/workflow-cli/cmd"
)
func safeGetValue(args map[string]interface{}, key string) string {
if args[key] == nil {
return ""
}
return args[key].(string)
}
func safeGetInt(args map[string]interface{}, key string) int {
if args[key] == nil {
return 0
}
retVal, err := strconv.Atoi(args[key].(string))
if err != nil {
log.Fatalf("could not convert %s to int: %v", args[key], err)
}
return retVal
}
func responseLimit(limit string) (int, error) {
if limit == "" {
return -1, nil
}
return strconv.Atoi(limit)
}
// PrintUsage runs if no matching command is found.
func PrintUsage(cmdr cmd.Commander) {
cmdr.PrintErrln("Found no matching command, try 'deis help'")
cmdr.PrintErrln("Usage: deis <command> [<args>...]")
}
func printHelp(argv []string, usage string) bool {
if len(argv) > 1 {
if argv[1] == "--help" || argv[1] == "-h" {
fmt.Print(usage)
return true
}
}
return false
}