1package main
2
3import (
4	"fmt"
5	"strings"
6)
7
8// CmdHelp is `direnv help`
9var CmdHelp = &Cmd{
10	Name:    "help",
11	Desc:    "shows this help",
12	Args:    []string{"[SHOW_PRIVATE]"},
13	Aliases: []string{"--help"},
14	Action: actionSimple(func(env Env, args []string) (err error) {
15		var showPrivate = len(args) > 1
16		fmt.Printf(`direnv v%s
17Usage: direnv COMMAND [...ARGS]
18
19Available commands
20------------------
21`, Version)
22		for _, cmd := range CmdList {
23			var opts string
24			if len(cmd.Args) > 0 {
25				opts = " " + strings.Join(cmd.Args, " ")
26			}
27			if cmd.Private {
28				if showPrivate {
29					fmt.Printf("*%s%s:\n  %s\n", cmd.Name, opts, cmd.Desc)
30				}
31			} else {
32				fmt.Printf("%s%s:\n  %s\n", cmd.Name, opts, cmd.Desc)
33			}
34		}
35
36		if showPrivate {
37			fmt.Println("* = private commands")
38		}
39		return
40	}),
41}
42