diff --git a/backend/info/info.go b/backend/overview/overview.go similarity index 95% rename from backend/info/info.go rename to backend/overview/overview.go index 2a60b03a9..11af24fd3 100644 --- a/backend/info/info.go +++ b/backend/overview/overview.go @@ -1,5 +1,5 @@ -// Package info provides info about a backend -package info +// Package overview provides info about a backend +package overview import ( "fmt" diff --git a/backend/info/info_test.go b/backend/overview/overview_test.go similarity index 98% rename from backend/info/info_test.go rename to backend/overview/overview_test.go index 3b04f06c6..f7441bfb8 100644 --- a/backend/info/info_test.go +++ b/backend/overview/overview_test.go @@ -1,4 +1,4 @@ -package info +package overview import ( "testing" diff --git a/docs/data/backends/embed.go b/docs/data/backends/embed.go index 6d00c636b..5c459848f 100644 --- a/docs/data/backends/embed.go +++ b/docs/data/backends/embed.go @@ -4,4 +4,6 @@ package backends import "embed" //go:embed *.yaml + +// BackendFS contains the backend YAML files var BackendFS embed.FS diff --git a/fs/config/config.go b/fs/config/config.go index 18b751db3..9f6ec5956 100644 --- a/fs/config/config.go +++ b/fs/config/config.go @@ -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) } diff --git a/fs/config/ui.go b/fs/config/ui.go index 845eb77e7..8e4eaaf90 100644 --- a/fs/config/ui.go +++ b/fs/config/ui.go @@ -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) diff --git a/fs/registry.go b/fs/registry.go index a11c57d22..6d50acaf4 100644 --- a/fs/registry.go +++ b/fs/registry.go @@ -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