forked from direnv/direnv
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcmd_help.go
41 lines (37 loc) · 777 Bytes
/
cmd_help.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
package main
import (
"fmt"
"strings"
)
// `direnv help`
var CmdHelp = &Cmd{
Name: "help",
Desc: "shows this help",
Args: []string{"[SHOW_PRIVATE]"},
Aliases: []string{"--help"},
Fn: func(env Env, args []string) (err error) {
var showPrivate = len(args) > 1
fmt.Printf(`direnv v%s
Usage: direnv COMMAND [...ARGS]
Available commands
------------------
`, VERSION)
for _, cmd := range CmdList {
var opts string
if len(cmd.Args) > 0 {
opts = " " + strings.Join(cmd.Args, " ")
}
if cmd.Private {
if showPrivate {
fmt.Printf("*%s%s:\n %s\n", cmd.Name, opts, cmd.Desc)
}
} else {
fmt.Printf("%s%s:\n %s\n", cmd.Name, opts, cmd.Desc)
}
}
if showPrivate {
fmt.Println("* = private commands")
}
return
},
}