Skip to content

Commit

Permalink
fix golang critics in commands
Browse files Browse the repository at this point in the history
  • Loading branch information
sni committed Mar 24, 2024
1 parent 4813381 commit 22f1f2d
Show file tree
Hide file tree
Showing 12 changed files with 314 additions and 248 deletions.
2 changes: 1 addition & 1 deletion pkg/snclient/commands/daemon.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ func init() {
All logs will be written to the configured logfile.
`,
GroupID: "daemon",
Run: func(cmd *cobra.Command, args []string) {
Run: func(_ *cobra.Command, _ []string) {
agentFlags.Mode = snclient.ModeServer
snc := snclient.NewAgent(agentFlags)
snc.CheckUpdateBinary("daemon")
Expand Down
12 changes: 9 additions & 3 deletions pkg/snclient/commands/dev.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
package commands

import (
"fmt"
"os"

"pkg/snclient"

"github.com/spf13/cobra"
Expand All @@ -10,9 +13,12 @@ func init() {
devCmd := &cobra.Command{
Use: "dev",
Short: "Collection of development commands",
Run: func(cmd *cobra.Command, args []string) {
Run: func(_ *cobra.Command, _ []string) {
rootCmd.SetArgs([]string{"help", "dev"})
rootCmd.Execute()
if err := rootCmd.Execute(); err != nil {
fmt.Fprintf(os.Stderr, "command failed: %s", err.Error())
os.Exit(3)
}
},
Hidden: true,
}
Expand All @@ -25,7 +31,7 @@ func init() {
Long: `start the agent and watch for file changes in the config files or the agent itself.
The agent will be restarted immediately on file changes.
`,
Run: func(cmd *cobra.Command, _ []string) {
Run: func(_ *cobra.Command, _ []string) {
agentFlags.Mode = snclient.ModeServer
snc := snclient.NewAgent(agentFlags)
snc.StartRestartWatcher()
Expand Down
4 changes: 2 additions & 2 deletions pkg/snclient/commands/hash.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ snclient hash
Run: func(cmd *cobra.Command, args []string) {
agentFlags.Mode = snclient.ModeOneShot
setInteractiveStdoutLogger()
input := ""
var input string
if len(args) > 0 {
input = args[0]
} else {
Expand All @@ -55,7 +55,7 @@ snclient hash

func readPassword(cmd *cobra.Command) string {
fmt.Fprintf(cmd.OutOrStdout(), "enter password to hash or hit ctrl+c to exit.\n")
b, _ := term.ReadPassword(int(syscall.Stdin))
b, _ := term.ReadPassword(int(syscall.Stdin)) //nolint:unconvert,nolintlint // unconvert detects a conversion here but it is one on windows

return string(b)
}
Loading

0 comments on commit 22f1f2d

Please sign in to comment.