Uh oh!
There was an error while loading. Please reload this page.
This repository was archived by the owner on Oct 17, 2021. It is now read-only.
- Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathcommand.go
More file actions
Latest commit
63 lines (55 loc) · 1.79 KB
/
Copy pathcommand.go
File metadata and controls
63 lines (55 loc) · 1.79 KB
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
51
52
53
54
55
56
57
58
59
60
61
62
63
package cli
import (
"strings"
"github.com/spf13/pflag"
)
// CommandSpec describes a Command's usage.
//
// It should not list flags.
typeCommandSpecstruct {
// Name is the name of the command.
// It should be the leaf name of the entire command. E.g `run` for the full
// command `sail run`.
Namestring
// Usage is the command's usage string.
// E.g "[flags] <path>"
Usagestring
// Desc is the description of the command.
// The first line is used as an abbreviated description.
Descstring
// RawArgs indicates that flags should not be parsed, and they should be deferred
// to the command.
RawArgsbool
// Hidden indicates that this command should not show up in it's parent's
// subcommand help.
Hiddenbool
// Aliases contains a list of alternative names that can be used for a particular command.
Aliases []string
}
// ShortDesc returns the first line of Desc.
func (cCommandSpec) ShortDesc() string {
returnstrings.Split(c.Desc, "\n")[0]
}
// HasAliases evaluates whether particular command has any alternative names.
func (cCommandSpec) HasAliases() bool {
returnlen(c.Aliases) >0
}
// Command describes a command or subcommand.
typeCommandinterface {
// Spec returns metadata about the command.
Spec() CommandSpec
// Run invokes the command's main routine with parsed flags.
Run(fl*pflag.FlagSet)
}
// ParentCommand is an optional interface for commands that have subcommands.
//
// A ParentCommand may pass itself into children as it creates them in order to
// pass high-level configuration and state.
typeParentCommandinterface {
Subcommands() []Command
}
// FlaggedCommand is an optional interface for commands that have flags.
typeFlaggedCommandinterface {
// RegisterFlags lets the command register flags which be sent to Handle.
RegisterFlags(fl*pflag.FlagSet)
}