From ae4c3173e30fc57ded4dbc9c8387f63c15a66114 Mon Sep 17 00:00:00 2001 From: Macmod Date: Tue, 27 Feb 2024 09:49:58 -0300 Subject: [PATCH] Adding version command. --- main.go | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/main.go b/main.go index 99c640d..a361b3e 100644 --- a/main.go +++ b/main.go @@ -405,9 +405,11 @@ func setupApp() { } func main() { + godapVer := "Godap v2.1.0" + rootCmd := &cobra.Command{ - Use: "godap", - Short: "A complete TUI for LDAP written in Golang.", + Use: "godap ", + Short: "A complete TUI for LDAP.", Args: cobra.ExactArgs(1), Run: func(cmd *cobra.Command, args []string) { ldapServer = args[0] @@ -452,6 +454,17 @@ func main() { rootCmd.Flags().BoolVarP(&ldaps, "ldaps", "S", false, "Use LDAPS for initial connection") rootCmd.Flags().StringVarP(&socksServer, "socks", "x", "", "Use a SOCKS proxy for initial connection") + versionCmd := &cobra.Command{ + Use: "version", + Short: "Print the version number of the application", + DisableFlagsInUseLine: true, + Run: func(cmd *cobra.Command, args []string) { + fmt.Println(godapVer) + }, + } + + rootCmd.AddCommand(versionCmd) + if err := rootCmd.Execute(); err != nil { fmt.Println(err) }