feat: use cobra and add some command
This commit is contained in:
@ -1,11 +1,11 @@
|
||||
package data
|
||||
|
||||
import "github.com/alist-org/alist/v3/cmd/args"
|
||||
import "github.com/alist-org/alist/v3/cmd/flags"
|
||||
|
||||
func InitData() {
|
||||
initUser()
|
||||
initSettings()
|
||||
if args.Dev {
|
||||
if flags.Dev {
|
||||
initDevData()
|
||||
initDevDo()
|
||||
}
|
||||
|
@ -3,7 +3,7 @@ package data
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/alist-org/alist/v3/cmd/args"
|
||||
"github.com/alist-org/alist/v3/cmd/flags"
|
||||
"github.com/alist-org/alist/v3/internal/db"
|
||||
"github.com/alist-org/alist/v3/internal/message"
|
||||
"github.com/alist-org/alist/v3/internal/model"
|
||||
@ -35,7 +35,7 @@ func initDevData() {
|
||||
}
|
||||
|
||||
func initDevDo() {
|
||||
if args.Dev {
|
||||
if flags.Dev {
|
||||
go func() {
|
||||
err := message.GetMessenger().WaitSend(map[string]string{
|
||||
"type": "dev",
|
||||
|
@ -1,7 +1,7 @@
|
||||
package data
|
||||
|
||||
import (
|
||||
"github.com/alist-org/alist/v3/cmd/args"
|
||||
"github.com/alist-org/alist/v3/cmd/flags"
|
||||
"github.com/alist-org/alist/v3/internal/conf"
|
||||
"github.com/alist-org/alist/v3/internal/db"
|
||||
"github.com/alist-org/alist/v3/internal/model"
|
||||
@ -60,7 +60,7 @@ func isActive(key string) bool {
|
||||
|
||||
func initialSettings() {
|
||||
var token string
|
||||
if args.Dev {
|
||||
if flags.Dev {
|
||||
token = "dev_token"
|
||||
} else {
|
||||
token = random.Token()
|
||||
@ -96,7 +96,7 @@ func initialSettings() {
|
||||
// single settings
|
||||
{Key: conf.Token, Value: token, Type: conf.TypeString, Group: model.SINGLE, Flag: model.PRIVATE},
|
||||
}
|
||||
if args.Dev {
|
||||
if flags.Dev {
|
||||
initialSettingItems = append(initialSettingItems, model.SettingItem{Key: "test_deprecated", Value: "test_value", Type: conf.TypeString, Flag: model.DEPRECATED})
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
package data
|
||||
|
||||
import (
|
||||
"github.com/alist-org/alist/v3/cmd/args"
|
||||
"github.com/alist-org/alist/v3/cmd/flags"
|
||||
"github.com/alist-org/alist/v3/internal/db"
|
||||
"github.com/alist-org/alist/v3/internal/model"
|
||||
"github.com/alist-org/alist/v3/pkg/utils/random"
|
||||
@ -13,7 +13,7 @@ import (
|
||||
func initUser() {
|
||||
admin, err := db.GetAdmin()
|
||||
adminPassword := random.String(8)
|
||||
if args.Dev {
|
||||
if flags.Dev {
|
||||
adminPassword = "admin"
|
||||
}
|
||||
if err != nil {
|
||||
@ -26,6 +26,8 @@ func initUser() {
|
||||
}
|
||||
if err := db.CreateUser(admin); err != nil {
|
||||
panic(err)
|
||||
} else {
|
||||
log.Infof("Successfully created the administrator user and the initial password is: %s", admin.Password)
|
||||
}
|
||||
} else {
|
||||
panic(err)
|
||||
@ -48,5 +50,4 @@ func initUser() {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
log.Infof("admin password: %+v", admin.Password)
|
||||
}
|
||||
|
Reference in New Issue
Block a user