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
1 changed files with 19 additions and 10 deletions
|
@ -298,10 +298,8 @@ func mustFindByName(name string) *fs.RegInfo {
|
||||||
return fs.MustFind(fsType)
|
return fs.MustFind(fsType)
|
||||||
}
|
}
|
||||||
|
|
||||||
// ShowRemote shows the contents of the remote
|
// printRemoteOptions prints the options of the remote
|
||||||
func ShowRemote(name string) {
|
func printRemoteOptions(name string, prefix string, sep string) {
|
||||||
fmt.Printf("--------------------\n")
|
|
||||||
fmt.Printf("[%s]\n", name)
|
|
||||||
fs := mustFindByName(name)
|
fs := mustFindByName(name)
|
||||||
for _, key := range LoadedData().GetKeyList(name) {
|
for _, key := range LoadedData().GetKeyList(name) {
|
||||||
isPassword := false
|
isPassword := false
|
||||||
|
@ -313,17 +311,28 @@ func ShowRemote(name string) {
|
||||||
}
|
}
|
||||||
value := FileGet(name, key)
|
value := FileGet(name, key)
|
||||||
if isPassword && value != "" {
|
if isPassword && value != "" {
|
||||||
fmt.Printf("%s = *** ENCRYPTED ***\n", key)
|
fmt.Printf("%s%s%s*** ENCRYPTED ***\n", prefix, key, sep)
|
||||||
} else {
|
} 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
|
// OkRemote prints the contents of the remote and ask if it is OK
|
||||||
func OkRemote(name string) bool {
|
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 {
|
switch i := CommandDefault([]string{"yYes this is OK", "eEdit this remote", "dDelete this remote"}, 0); i {
|
||||||
case 'y':
|
case 'y':
|
||||||
return true
|
return true
|
||||||
|
@ -539,8 +548,8 @@ func NewRemote(ctx context.Context, name string) error {
|
||||||
|
|
||||||
// EditRemote gets the user to edit a remote
|
// EditRemote gets the user to edit a remote
|
||||||
func EditRemote(ctx context.Context, ri *fs.RegInfo, name string) error {
|
func EditRemote(ctx context.Context, ri *fs.RegInfo, name string) error {
|
||||||
fmt.Printf("Edit remote\n")
|
fmt.Printf("Edit existing %q remote with options:\n", name)
|
||||||
ShowRemote(name)
|
listRemoteOptions(name)
|
||||||
newSection()
|
newSection()
|
||||||
for {
|
for {
|
||||||
_, err := UpdateRemote(ctx, name, nil, UpdateRemoteOpt{
|
_, err := UpdateRemote(ctx, name, nil, UpdateRemoteOpt{
|
||||||
|
|
Loading…
Reference in a new issue