Skip to content

Commit bc2c84b

Browse files
vqhuyarlolra
authored andcommitted
Add version command
1 parent e13a234 commit bc2c84b

File tree

4 files changed

+70
-0
lines changed

4 files changed

+70
-0
lines changed
+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
package cmd
2+
3+
import (
4+
"fmt"
5+
6+
"github.com/coniks-sys/coniks-go/internal"
7+
"github.com/spf13/cobra"
8+
)
9+
10+
var versionCmd = &cobra.Command{
11+
Use: "version",
12+
Short: "Print the version number of coniksbot.",
13+
Long: `Print the version number of coniksbot.`,
14+
Run: func(cmd *cobra.Command, args []string) {
15+
fmt.Println("All software has versions. This is coniksbot's:")
16+
fmt.Println("coniksbot v" + internal.Version)
17+
},
18+
}
19+
20+
func init() {
21+
RootCmd.AddCommand(versionCmd)
22+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
package cmd
2+
3+
import (
4+
"fmt"
5+
6+
"github.com/coniks-sys/coniks-go/internal"
7+
"github.com/spf13/cobra"
8+
)
9+
10+
var versionCmd = &cobra.Command{
11+
Use: "version",
12+
Short: "Print the version number of coniksclient.",
13+
Long: `Print the version number of coniksclient.`,
14+
Run: func(cmd *cobra.Command, args []string) {
15+
fmt.Println("All software has versions. This is coniksclient's:")
16+
fmt.Println("coniksclient v" + internal.Version)
17+
},
18+
}
19+
20+
func init() {
21+
RootCmd.AddCommand(versionCmd)
22+
}

internal/version.go

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
package internal
2+
3+
// Version of executables.
4+
var Version = "0.0.0+git"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
package cmd
2+
3+
import (
4+
"fmt"
5+
6+
"github.com/coniks-sys/coniks-go/internal"
7+
"github.com/spf13/cobra"
8+
)
9+
10+
var versionCmd = &cobra.Command{
11+
Use: "version",
12+
Short: "Print the version number of coniksserver.",
13+
Long: `Print the version number of coniksserver.`,
14+
Run: func(cmd *cobra.Command, args []string) {
15+
fmt.Println("All software has versions. This is coniksserver's:")
16+
fmt.Println("coniksserver v" + internal.Version)
17+
},
18+
}
19+
20+
func init() {
21+
RootCmd.AddCommand(versionCmd)
22+
}

0 commit comments

Comments
 (0)