-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcommand.go
More file actions
48 lines (39 loc) · 911 Bytes
/
command.go
File metadata and controls
48 lines (39 loc) · 911 Bytes
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
package main
import (
flags "github.com/jessevdk/go-flags"
"go.uber.org/zap"
)
type command interface {
flags.Commander
Name() string
ShortDescription() string
LongDescription() string
}
type baseCommand struct {
name string
shortDesc string
longDesc string
opts *options // global flags
logger *zap.Logger
}
func newBaseCommand(name, short, long string, opts *options, logger *zap.Logger) baseCommand {
return baseCommand{
name: name,
shortDesc: short,
longDesc: long,
opts: opts,
logger: logger,
}
}
// Name returns the name of a command
func (c baseCommand) Name() string {
return c.name
}
// ShortDescription return the short description of a command
func (c baseCommand) ShortDescription() string {
return c.shortDesc
}
// LongDescription returns the long description of a command
func (c baseCommand) LongDescription() string {
return c.longDesc
}