File: help_command.go

package info (click to toggle)
golang-ginkgo 1.2.0%2Bgit20161006.acfa16a-1
  • links: PTS, VCS
  • area: main
  • in suites: buster, stretch
  • size: 1,324 kB
  • ctags: 1,210
  • sloc: makefile: 12
file content (31 lines) | stat: -rw-r--r-- 640 bytes parent folder | download | duplicates (6)
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
package main

import (
	"flag"
	"fmt"
)

func BuildHelpCommand() *Command {
	return &Command{
		Name:         "help",
		FlagSet:      flag.NewFlagSet("help", flag.ExitOnError),
		UsageCommand: "ginkgo help <COMMAND>",
		Usage: []string{
			"Print usage information.  If a command is passed in, print usage information just for that command.",
		},
		Command: printHelp,
	}
}

func printHelp(args []string, additionalArgs []string) {
	if len(args) == 0 {
		usage()
	} else {
		command, found := commandMatching(args[0])
		if !found {
			complainAndQuit(fmt.Sprintf("Unknown command: %s", args[0]))
		}

		usageForCommand(command, true)
	}
}