alist/cmd/admin.go

41 lines
1.1 KiB
Go
Raw Normal View History

2022-08-07 05:09:59 +00:00
/*
Copyright © 2022 NAME HERE <EMAIL ADDRESS>
*/
package cmd
import (
"github.com/alist-org/alist/v3/internal/op"
2022-08-30 08:13:01 +00:00
"github.com/alist-org/alist/v3/pkg/utils"
2022-08-07 05:09:59 +00:00
"github.com/spf13/cobra"
)
2022-12-18 11:53:39 +00:00
// PasswordCmd represents the password command
var PasswordCmd = &cobra.Command{
2022-09-10 08:39:08 +00:00
Use: "admin",
Aliases: []string{"password"},
Short: "Show admin user's info",
2022-08-07 05:09:59 +00:00
Run: func(cmd *cobra.Command, args []string) {
Init()
admin, err := op.GetAdmin()
2022-08-07 05:09:59 +00:00
if err != nil {
2022-08-30 08:13:01 +00:00
utils.Log.Errorf("failed get admin user: %+v", err)
2022-08-07 05:09:59 +00:00
} else {
2022-09-10 08:39:08 +00:00
utils.Log.Infof("admin user's info: \nusername: %s\npassword: %s", admin.Username, admin.Password)
2022-08-07 05:09:59 +00:00
}
},
}
func init() {
2022-12-18 11:53:39 +00:00
RootCmd.AddCommand(PasswordCmd)
2022-08-07 05:09:59 +00:00
// Here you will define your flags and configuration settings.
// Cobra supports Persistent Flags which will work for this command
// and all subcommands, e.g.:
// passwordCmd.PersistentFlags().String("foo", "", "A help for foo")
// Cobra supports local flags which will only run when this command
// is called directly, e.g.:
// passwordCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle")
}