diff options
| author | theimpostor <sahirhoda@gmail.com> | 2023-08-03 21:42:22 -0500 |
|---|---|---|
| committer | theimpostor <sahirhoda@gmail.com> | 2023-08-03 21:42:22 -0500 |
| commit | b0591174dc3549cc91340df46604ab49df35b11b (patch) | |
| tree | b45bfcd8eedf56ff947c36fd6a936e5f5454b4c7 /main.go | |
| parent | 827a816ae857bd5f8742504b4a75a256ca41bd9b (diff) | |
add version command
Diffstat (limited to 'main.go')
| -rw-r--r-- | main.go | 15 |
1 files changed, 15 insertions, 0 deletions
@@ -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() { |
