File tree Expand file tree Collapse file tree 3 files changed +17
-3
lines changed
Expand file tree Collapse file tree 3 files changed +17
-3
lines changed Original file line number Diff line number Diff line change @@ -3,7 +3,7 @@ package local
33import "github.com/alist-org/alist/v3/internal/driver"
44
55type Addition struct {
6- RootFolder string `json:"root_folder" type:"string" help:"root folder path" default:"/"`
6+ RootFolder string `json:"root_folder" help:"root folder path" default:"/"`
77}
88
99var config = driver.Config {
Original file line number Diff line number Diff line change @@ -2,6 +2,15 @@ package driver
22
33type Additional interface {}
44
5+ type Select string
6+
7+ const (
8+ TypeString = "string"
9+ TypeSelect = "select"
10+ TypeBool = "bool"
11+ TypeText = "text"
12+ )
13+
514type Item struct {
615 Name string `json:"name"`
716 Type string `json:"type"`
Original file line number Diff line number Diff line change @@ -3,6 +3,7 @@ package driver
33import (
44 log "github.com/sirupsen/logrus"
55 "reflect"
6+ "strings"
67)
78
89type New func () Driver
@@ -73,19 +74,23 @@ func getMainItems(config Config) []Item {
7374func getAdditionalItems (t reflect.Type ) []Item {
7475 var items []Item
7576 for i := 0 ; i < t .NumField (); i ++ {
76- tag := t .Field (i ).Tag
77+ field := t .Field (i )
78+ tag := field .Tag
7779 ignore , ok := tag .Lookup ("ignore" )
7880 if ! ok || ignore == "false" {
7981 continue
8082 }
8183 item := Item {
8284 Name : tag .Get ("json" ),
83- Type : tag . Get ( "type" ),
85+ Type : strings . ToLower ( field . Name ),
8486 Default : tag .Get ("default" ),
8587 Values : tag .Get ("values" ),
8688 Required : tag .Get ("required" ) == "true" ,
8789 Help : tag .Get ("help" ),
8890 }
91+ if tag .Get ("type" ) != "" {
92+ item .Type = tag .Get ("type" )
93+ }
8994 // set default type to string
9095 if item .Type == "" {
9196 item .Type = "string"
You can’t perform that action at this time.
0 commit comments