From b246584a02df46afece9b7f5d55df83fc9a31a86 Mon Sep 17 00:00:00 2001 From: albertony <12441419+albertony@users.noreply.github.com> Date: Sat, 28 May 2022 15:53:47 +0200 Subject: [PATCH] config: more readable listing of remote options Differentiate output of 'config show remote' command from listing options as part of interactive config process for consistency: 'config show remote' consistent with 'config show', while listing in interactive config consistent with other output. See #6211 --- fs/config/ui.go | 29 +++++++++++++++++++---------- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/fs/config/ui.go b/fs/config/ui.go index 6dbe0c5d3..73b2925b2 100644 --- a/fs/config/ui.go +++ b/fs/config/ui.go @@ -298,10 +298,8 @@ func mustFindByName(name string) *fs.RegInfo { return fs.MustFind(fsType) } -// ShowRemote shows the contents of the remote -func ShowRemote(name string) { - fmt.Printf("--------------------\n") - fmt.Printf("[%s]\n", name) +// printRemoteOptions prints the options of the remote +func printRemoteOptions(name string, prefix string, sep string) { fs := mustFindByName(name) for _, key := range LoadedData().GetKeyList(name) { isPassword := false @@ -313,17 +311,28 @@ func ShowRemote(name string) { } value := FileGet(name, key) if isPassword && value != "" { - fmt.Printf("%s = *** ENCRYPTED ***\n", key) + fmt.Printf("%s%s%s*** ENCRYPTED ***\n", prefix, key, sep) } else { - fmt.Printf("%s = %s\n", key, value) + fmt.Printf("%s%s%s%s\n", prefix, key, sep, value) } } - fmt.Printf("--------------------\n") +} + +// listRemoteOptions lists the options of the remote +func listRemoteOptions(name string) { + printRemoteOptions(name, "- ", ": ") +} + +// ShowRemote shows the contents of the remote in config file format +func ShowRemote(name string) { + fmt.Printf("[%s]\n", name) + printRemoteOptions(name, "", " = ") } // OkRemote prints the contents of the remote and ask if it is OK func OkRemote(name string) bool { - ShowRemote(name) + fmt.Printf("Configuration of %q remote:\n", name) + listRemoteOptions(name) switch i := CommandDefault([]string{"yYes this is OK", "eEdit this remote", "dDelete this remote"}, 0); i { case 'y': return true @@ -539,8 +548,8 @@ func NewRemote(ctx context.Context, name string) error { // EditRemote gets the user to edit a remote func EditRemote(ctx context.Context, ri *fs.RegInfo, name string) error { - fmt.Printf("Edit remote\n") - ShowRemote(name) + fmt.Printf("Edit existing %q remote with options:\n", name) + listRemoteOptions(name) newSection() for { _, err := UpdateRemote(ctx, name, nil, UpdateRemoteOpt{