Skip to content

Commit aa93898

Browse files
committed
add version command
1 parent beef35a commit aa93898

File tree

1 file changed

+19
-2
lines changed

1 file changed

+19
-2
lines changed

cmd/cain.go

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ func NewRootCmd(args []string) *cobra.Command {
3131
cmd.AddCommand(NewBackupCmd(out))
3232
cmd.AddCommand(NewRestoreCmd(out))
3333
cmd.AddCommand(NewSchemaCmd(out))
34+
cmd.AddCommand(NewVersionCmd(out))
3435

3536
return cmd
3637
}
@@ -52,7 +53,7 @@ func NewBackupCmd(out io.Writer) *cobra.Command {
5253

5354
cmd := &cobra.Command{
5455
Use: "backup",
55-
Short: "backup cassandra cluster to S3",
56+
Short: "backup cassandra cluster to cloud storage",
5657
Long: ``,
5758
Run: func(cmd *cobra.Command, args []string) {
5859
if _, err := cain.Backup(b.namespace, b.selector, b.container, b.keyspace, b.dst, b.parallel); err != nil {
@@ -90,7 +91,7 @@ func NewRestoreCmd(out io.Writer) *cobra.Command {
9091

9192
cmd := &cobra.Command{
9293
Use: "restore",
93-
Short: "restore cassandra cluster from S3",
94+
Short: "restore cassandra cluster from cloud storage",
9495
Long: ``,
9596
Run: func(cmd *cobra.Command, args []string) {
9697
if err := cain.Restore(r.src, r.keyspace, r.tag, r.namespace, r.selector, r.container, r.parallel); err != nil {
@@ -155,3 +156,19 @@ func NewSchemaCmd(out io.Writer) *cobra.Command {
155156

156157
return cmd
157158
}
159+
160+
var GitTag, GitCommit string
161+
162+
// NewVersionCmd prints version information
163+
func NewVersionCmd(out io.Writer) *cobra.Command {
164+
cmd := &cobra.Command{
165+
Use: "version",
166+
Short: "Print version information",
167+
Long: ``,
168+
Run: func(cmd *cobra.Command, args []string) {
169+
fmt.Printf("Version %s (git-%s)\n", GitTag, GitCommit)
170+
},
171+
}
172+
173+
return cmd
174+
}

0 commit comments

Comments
 (0)