-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathshortcuts.go
More file actions
50 lines (38 loc) · 917 Bytes
/
shortcuts.go
File metadata and controls
50 lines (38 loc) · 917 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
package parser
import (
docopt "github.com/docopt/docopt-go"
"github.com/drycc/workflow-cli/cmd"
)
// Shortcuts displays all relevant shortcuts for the CLI.
func Shortcuts(argv []string, cmdr cmd.Commander) error {
usage := `
Valid commands for shortcuts:
shortcuts:list list all relevant shortcuts for the CLI
Use 'drycc help [command]' to learn more.
`
switch argv[0] {
case "shortcuts:list":
return shortcutsList(argv, cmdr)
default:
if printHelp(argv, usage) {
return nil
}
if argv[0] == "shortcuts" {
argv[0] = "shortcuts:list"
return shortcutsList(argv, cmdr)
}
PrintUsage(cmdr)
return nil
}
}
func shortcutsList(argv []string, cmdr cmd.Commander) error {
usage := `
Lists all relevant shortcuts for the CLI
Usage: drycc shortcuts:list
`
_, err := docopt.Parse(usage, argv, true, "", false, true)
if err != nil {
return err
}
return cmdr.ShortcutsList()
}