-
-
Notifications
You must be signed in to change notification settings - Fork 12
/
cmd_version.go
59 lines (49 loc) · 897 Bytes
/
cmd_version.go
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
// Version
//
// The version sub-command reports our version and terminates.
package main
import (
"context"
"flag"
"fmt"
"io"
"os"
"github.com/google/subcommands"
)
//
// modified during testing
//
var out io.Writer = os.Stdout
var (
version = "master"
)
type versionCmd struct {
}
//
// Glue
//
func (*versionCmd) Name() string { return "version" }
func (*versionCmd) Synopsis() string { return "Show our version." }
func (*versionCmd) Usage() string {
return `version :
Report upon our version, and exit.
`
}
//
// Flag setup.
//
func (p *versionCmd) SetFlags(f *flag.FlagSet) {
}
//
// Show the version - using the "out"-writer.
//
func showVersion() {
fmt.Fprintf(out, "%s\n", version)
}
//
// Entry-point.
//
func (p *versionCmd) Execute(_ context.Context, f *flag.FlagSet, _ ...interface{}) subcommands.ExitStatus {
showVersion()
return subcommands.ExitSuccess
}