refactor: build cobra commands with constructors

This commit is contained in:
Mathis Maquenne
2026-08-05 11:35:52 +02:00
parent 0ab25addd5
commit 3c9da5f24a
6 changed files with 121 additions and 111 deletions
+13 -15
View File
@@ -7,21 +7,19 @@ import (
"github.com/spf13/cobra"
)
var logoutCmd = &cobra.Command{
Use: "logout",
Short: "Remove stored Deezer credentials",
Args: cobra.NoArgs,
RunE: func(cmd *cobra.Command, args []string) error {
if err := auth.Clear(); err != nil {
return err
}
func newLogoutCmd() *cobra.Command {
return &cobra.Command{
Use: "logout",
Short: "Remove stored Deezer credentials",
Args: cobra.NoArgs,
RunE: func(cmd *cobra.Command, args []string) error {
if err := auth.Clear(); err != nil {
return err
}
fmt.Println("Successfully logged out.")
fmt.Println("Successfully logged out.")
return nil
},
}
func init() {
RootCmd.AddCommand(logoutCmd)
return nil
},
}
}