Repository navigation
Expand file tree
/
Copy pathinterface.go
More file actions
58 lines (49 loc) · 1.84 KB
/
Copy pathinterface.go
File metadata and controls
58 lines (49 loc) · 1.84 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
package cli
import (
"context"
"flag"
"io"
"time"
)
// 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
}
// RunFunc runs a command, see Command.Run.
type RunFunc func(ctx context.Context) error
// Middleware wraps the run of command c: it may prepare the context, check
// or clean up around next, or skip it. Added with CLI.Use.
type Middleware func(c Command, next RunFunc) RunFunc
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.
// It runs after the flag and `arg` fields are set, with the positional arguments.
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
}