owl-blogs/cmd/owl/reset_password.go

27 lines
673 B
Go
Raw Normal View History

2023-08-12 18:39:07 +00:00
package main
import (
"owl-blogs/infra"
"github.com/spf13/cobra"
)
func init() {
rootCmd.AddCommand(resetPasswordCmd)
resetPasswordCmd.Flags().StringVarP(&user, "user", "u", "", "The user name")
resetPasswordCmd.MarkFlagRequired("user")
resetPasswordCmd.Flags().StringVarP(&password, "password", "p", "", "The new password")
resetPasswordCmd.MarkFlagRequired("password")
}
var resetPasswordCmd = &cobra.Command{
Use: "reset-password",
Short: "Resets the password of an author",
Long: `Resets the password of an author`,
Run: func(cmd *cobra.Command, args []string) {
db := infra.NewSqliteDB(DbPath)
App(db).AuthorService.Create(user, password)
},
}