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 overview provides info about a backend
|
||||||
package info
|
package overview
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package info
|
package overview
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"testing"
|
"testing"
|
||||||
@@ -4,4 +4,6 @@ package backends
|
|||||||
import "embed"
|
import "embed"
|
||||||
|
|
||||||
//go:embed *.yaml
|
//go:embed *.yaml
|
||||||
|
|
||||||
|
// BackendFS contains the backend YAML files
|
||||||
var BackendFS embed.FS
|
var BackendFS embed.FS
|
||||||
|
|||||||
+19
-1
@@ -24,6 +24,7 @@ import (
|
|||||||
"github.com/rclone/rclone/fs/rc"
|
"github.com/rclone/rclone/fs/rc"
|
||||||
"github.com/rclone/rclone/lib/file"
|
"github.com/rclone/rclone/lib/file"
|
||||||
"github.com/rclone/rclone/lib/random"
|
"github.com/rclone/rclone/lib/random"
|
||||||
|
"github.com/rclone/rclone/lib/terminal"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@@ -709,6 +710,23 @@ func JSONListProviders() error {
|
|||||||
return nil
|
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
|
// fsOption returns an Option describing the possible remotes
|
||||||
func fsOption() *fs.Option {
|
func fsOption() *fs.Option {
|
||||||
o := &fs.Option{
|
o := &fs.Option{
|
||||||
@@ -723,7 +741,7 @@ func fsOption() *fs.Option {
|
|||||||
}
|
}
|
||||||
example := fs.OptionExample{
|
example := fs.OptionExample{
|
||||||
Value: item.Name,
|
Value: item.Name,
|
||||||
Help: item.Description,
|
Help: item.Description + " - " + colorizeTier(item.Overview.Tier),
|
||||||
}
|
}
|
||||||
o.Examples = append(o.Examples, example)
|
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)
|
number = fmt.Sprintf("%2d", pos)
|
||||||
}
|
}
|
||||||
fmt.Printf("%s %c %s\n", number, sep, line)
|
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)
|
terminal.WriteString(terminal.Reset)
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
|
"github.com/rclone/rclone/backend/overview"
|
||||||
"github.com/rclone/rclone/fs/config/configmap"
|
"github.com/rclone/rclone/fs/config/configmap"
|
||||||
"github.com/rclone/rclone/fs/config/configstruct"
|
"github.com/rclone/rclone/fs/config/configstruct"
|
||||||
"github.com/rclone/rclone/lib/errcount"
|
"github.com/rclone/rclone/lib/errcount"
|
||||||
@@ -53,6 +54,8 @@ type RegInfo struct {
|
|||||||
Hide bool
|
Hide bool
|
||||||
// MetadataInfo help about the metadata in use in this backend
|
// MetadataInfo help about the metadata in use in this backend
|
||||||
MetadataInfo *MetadataInfo
|
MetadataInfo *MetadataInfo
|
||||||
|
// Overview about the backend
|
||||||
|
Overview *overview.BackendConfig
|
||||||
}
|
}
|
||||||
|
|
||||||
// FileName returns the on disk file name for this backend
|
// FileName returns the on disk file name for this backend
|
||||||
@@ -431,6 +434,12 @@ func Register(info *RegInfo) {
|
|||||||
}
|
}
|
||||||
info.Options = append(info.Options, optDescription)
|
info.Options = append(info.Options, optDescription)
|
||||||
Registry = append(Registry, info)
|
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 {
|
for _, alias := range info.Aliases {
|
||||||
// Copy the info block and rename and hide the alias and options
|
// Copy the info block and rename and hide the alias and options
|
||||||
aliasInfo := *info
|
aliasInfo := *info
|
||||||
|
|||||||
Reference in New Issue
Block a user