/
command.go
49 lines (39 loc) · 964 Bytes
/
command.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
package versionCmd
import (
// Stdlib
"fmt"
"os"
// Internal
"github.com/salsaflow/salsaflow/app/appflags"
"github.com/salsaflow/salsaflow/commands/version/bump"
"github.com/salsaflow/salsaflow/errs"
"github.com/salsaflow/salsaflow/version"
// Other
"gopkg.in/tchap/gocli.v2"
)
var Command = &gocli.Command{
UsageLine: "version",
Short: "print the current project version",
Long: `
Print the project version string as stored in the current branch.
To check the version of SalsaFlow itself, use -version.
There are also some subcommands available. Check them out.
`,
Action: func(cmd *gocli.Command, args []string) {
if len(args) != 0 {
cmd.Usage()
os.Exit(2)
}
ver, err := version.Get()
if err != nil {
errs.Fatal(err)
}
fmt.Println(ver)
},
}
func init() {
// Register global flags.
appflags.RegisterGlobalFlags(&Command.Flags)
// Register subcommands.
Command.MustRegisterSubcommand(bumpCmd.Command)
}