mirror of
https://github.com/rclone/rclone.git
synced 2024-12-23 07:29:35 +01:00
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
This commit is contained in:
parent
61a75bfe07
commit
b246584a02
@ -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{
|
||||
|
Loading…
Reference in New Issue
Block a user