-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathutils.go
More file actions
37 lines (30 loc) · 775 Bytes
/
utils.go
File metadata and controls
37 lines (30 loc) · 775 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
package parser
import (
"fmt"
"strconv"
)
// docopt expects commands to be in the proper format, but we split them apart for
// routing purposes, so the commands need to be recombined.
func combineCommand(argv []string) []string {
if len(argv) > 1 {
return append([]string{argv[0] + ":" + argv[1]}, argv[2:]...)
}
return nil
}
func safeGetValue(args map[string]interface{}, key string) string {
if args[key] == nil {
return ""
}
return args[key].(string)
}
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() {
fmt.Println("Found no matching command, try 'deis help'")
fmt.Println("Usage: deis <command> [<args>...]")
}