fs/config: add tier to config wizard
This makes the overview from the docs accessible in the code.
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
// Package info provides info about a backend
|
||||
package info
|
||||
// Package overview provides info about a backend
|
||||
package overview
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
@@ -1,4 +1,4 @@
|
||||
package info
|
||||
package overview
|
||||
|
||||
import (
|
||||
"testing"
|
||||
@@ -4,4 +4,6 @@ package backends
|
||||
import "embed"
|
||||
|
||||
//go:embed *.yaml
|
||||
|
||||
// BackendFS contains the backend YAML files
|
||||
var BackendFS embed.FS
|
||||
|
||||
+19
-1
@@ -24,6 +24,7 @@ import (
|
||||
"github.com/rclone/rclone/fs/rc"
|
||||
"github.com/rclone/rclone/lib/file"
|
||||
"github.com/rclone/rclone/lib/random"
|
||||
"github.com/rclone/rclone/lib/terminal"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -709,6 +710,23 @@ func JSONListProviders() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// colorizeTier applies a color based on level of support
|
||||
func colorizeTier(tier string) string {
|
||||
var color string
|
||||
switch tier {
|
||||
case "Tier 1", "Tier 2":
|
||||
color = terminal.GreenBg
|
||||
case "Tier 3":
|
||||
color = terminal.YellowBg
|
||||
case "Tier 4", "Tier 5":
|
||||
color = terminal.RedBg
|
||||
default:
|
||||
return tier
|
||||
}
|
||||
|
||||
return terminal.BlackFg + color + tier + terminal.Reset
|
||||
}
|
||||
|
||||
// fsOption returns an Option describing the possible remotes
|
||||
func fsOption() *fs.Option {
|
||||
o := &fs.Option{
|
||||
@@ -723,7 +741,7 @@ func fsOption() *fs.Option {
|
||||
}
|
||||
example := fs.OptionExample{
|
||||
Value: item.Name,
|
||||
Help: item.Description,
|
||||
Help: item.Description + " - " + colorizeTier(item.Overview.Tier),
|
||||
}
|
||||
o.Examples = append(o.Examples, example)
|
||||
}
|
||||
|
||||
@@ -167,6 +167,8 @@ func Choose(what string, kind string, choices, help []string, defaultValue strin
|
||||
number = fmt.Sprintf("%2d", pos)
|
||||
}
|
||||
fmt.Printf("%s %c %s\n", number, sep, line)
|
||||
// reapply color for second line
|
||||
terminal.WriteString(attributes[(pos-1)%len(attributes)])
|
||||
}
|
||||
}
|
||||
terminal.WriteString(terminal.Reset)
|
||||
|
||||
@@ -13,6 +13,7 @@ import (
|
||||
"strings"
|
||||
"sync"
|
||||
|
||||
"github.com/rclone/rclone/backend/overview"
|
||||
"github.com/rclone/rclone/fs/config/configmap"
|
||||
"github.com/rclone/rclone/fs/config/configstruct"
|
||||
"github.com/rclone/rclone/lib/errcount"
|
||||
@@ -53,6 +54,8 @@ type RegInfo struct {
|
||||
Hide bool
|
||||
// MetadataInfo help about the metadata in use in this backend
|
||||
MetadataInfo *MetadataInfo
|
||||
// Overview about the backend
|
||||
Overview *overview.BackendConfig
|
||||
}
|
||||
|
||||
// FileName returns the on disk file name for this backend
|
||||
@@ -431,6 +434,12 @@ func Register(info *RegInfo) {
|
||||
}
|
||||
info.Options = append(info.Options, optDescription)
|
||||
Registry = append(Registry, info)
|
||||
var err error
|
||||
info.Overview, err = overview.GetBackendConfig(strings.ReplaceAll(info.Name, " ", ""))
|
||||
if err != nil {
|
||||
Errorf(nil, "internal error: no overview data found for %q", info.Name)
|
||||
info.Overview = new(overview.BackendConfig)
|
||||
}
|
||||
for _, alias := range info.Aliases {
|
||||
// Copy the info block and rename and hide the alias and options
|
||||
aliasInfo := *info
|
||||
|
||||
Reference in New Issue
Block a user