From b0591174dc3549cc91340df46604ab49df35b11b Mon Sep 17 00:00:00 2001 From: theimpostor Date: Thu, 3 Aug 2023 21:42:22 -0500 Subject: add version command --- main.go | 15 +++++++++++++++ 1 file changed, 15 insertions(+) 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() { -- cgit v1.2.3