summaryrefslogtreecommitdiff
path: root/main.go
diff options
context:
space:
mode:
authortheimpostor <sahirhoda@gmail.com>2023-08-03 21:42:22 -0500
committertheimpostor <sahirhoda@gmail.com>2023-08-03 21:42:22 -0500
commitb0591174dc3549cc91340df46604ab49df35b11b (patch)
treeb45bfcd8eedf56ff947c36fd6a936e5f5454b4c7 /main.go
parent827a816ae857bd5f8742504b4a75a256ca41bd9b (diff)
add version command
Diffstat (limited to 'main.go')
-rw-r--r--main.go15
1 files changed, 15 insertions, 0 deletions
diff --git a/main.go b/main.go
index 52d4f5e..18314b7 100644
--- a/main.go
+++ b/main.go
@@ -14,6 +14,7 @@ import (
"time"
"github.com/spf13/cobra"
+ "runtime/debug"
)
var (
@@ -253,6 +254,19 @@ osc paste`,
},
}
+var versionCmd = &cobra.Command{
+ Use: "version",
+ Short: "Outputs version information",
+ Long: `Outputs version information`,
+ Run: func(cmd *cobra.Command, args []string) {
+ if info, ok := debug.ReadBuildInfo(); !ok {
+ fmt.Println(`Unable to obtain build info.`)
+ } else {
+ fmt.Println(info.Main.Version)
+ }
+ },
+}
+
var rootCmd = &cobra.Command{
Use: "osc",
Short: "Reads or writes the system clipboard using the ANSI OSC52 escape sequence",
@@ -265,6 +279,7 @@ func init() {
rootCmd.AddCommand(copyCmd)
rootCmd.AddCommand(pasteCmd)
+ rootCmd.AddCommand(versionCmd)
}
func main() {