Skip to content

Commit 3deefdf

Browse files
Move version command to banner
1 parent c4288d9 commit 3deefdf

1 file changed

Lines changed: 13 additions & 17 deletions

File tree

cmd/keycred/main.go

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,11 @@ import (
1616
"github.com/RedTeamPentesting/adauth/ldapauth"
1717
)
1818

19-
var version string
19+
var (
20+
version string
21+
banner = "keycred by RedTeam Pentesting"
22+
description = "keycred is a tool to create and manage KeyCredentialLinks developed by RedTeam Pentesting GmbH"
23+
)
2024

2125
//nolint:maintidx
2226
func run() error {
@@ -35,10 +39,17 @@ func run() error {
3539
cobra.EnableCommandSorting = false
3640
rootCmd := &cobra.Command{
3741
Use: binaryName(),
38-
Short: "Create and manage KeyCredentialLinks",
42+
Short: description,
3943
SilenceErrors: true,
4044
SilenceUsage: true,
4145
PersistentPreRunE: func(cmd *cobra.Command, args []string) (err error) {
46+
fullBanner := banner
47+
if version != "" {
48+
fullBanner += " " + version
49+
}
50+
51+
fmt.Println("\x1b[2m" + fullBanner + "\x1b[0m")
52+
4253
ldapOpts.SetDialer(adauth.DialerWithSOCKS5ProxyIfSet(socksServer, nil))
4354

4455
return nil
@@ -393,21 +404,6 @@ func run() error {
393404
},
394405
})
395406

396-
rootCmd.AddCommand(&cobra.Command{
397-
Use: "version",
398-
Short: "Print the version",
399-
SilenceErrors: true,
400-
SilenceUsage: true,
401-
Args: cobra.NoArgs,
402-
Run: func(cmd *cobra.Command, args []string) {
403-
if version != "" {
404-
fmt.Println(version)
405-
} else {
406-
fmt.Println("unknown")
407-
}
408-
},
409-
})
410-
411407
return rootCmd.ExecuteContext(context.Background())
412408
}
413409

0 commit comments

Comments
 (0)