-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinterface.go
More file actions
50 lines (43 loc) · 1.48 KB
/
interface.go
File metadata and controls
50 lines (43 loc) · 1.48 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
package cli
import (
"context"
"flag"
"io"
"time"
)
// A command is a runnable command of a CLI.
type Command interface {
// Help should return long-form help text that includes the command-line
// usage, a brief few sentences explaining the function of the command.
Help() string
// Synopsis should return a one-line, short synopsis of the command.
Synopsis() string
// Run should run the actual command with the given Context
Run(ctx context.Context) error
}
type SubCommands interface {
// SubCommand should return a list of sub commands
SubCommands() map[string]Command
}
type ParseHelper interface {
// Parse should help to validate flags, and add extra options
Parse([]string) error
}
// Flagger is an interface satisfied by flag.FlagSet and other implementations
// of flags.
type Flagger interface {
Parse([]string) error
StringVar(p *string, name string, value string, usage string)
IntVar(p *int, name string, value int, usage string)
Int64Var(p *int64, name string, value int64, usage string)
BoolVar(p *bool, name string, value bool, usage string)
UintVar(p *uint, name string, value uint, usage string)
Uint64Var(p *uint64, name string, value uint64, usage string)
Float64Var(p *float64, name string, value float64, usage string)
DurationVar(p *time.Duration, name string, value time.Duration, usage string)
Set(name string, value string) error
SetOutput(output io.Writer)
Var(value flag.Value, name string, usage string)
VisitAll(fn func(*flag.Flag))
Args() []string
}