forked from TrueCloudLab/rclone
Make config chooser easier to understand
This commit is contained in:
parent
e08e35984c
commit
95e4d837ef
1 changed files with 24 additions and 3 deletions
27
fs/config.go
27
fs/config.go
|
@ -571,13 +571,34 @@ func Choose(what string, defaults, help []string, newOk bool) string {
|
||||||
}
|
}
|
||||||
fmt.Println()
|
fmt.Println()
|
||||||
for i, text := range defaults {
|
for i, text := range defaults {
|
||||||
|
var lines []string
|
||||||
if help != nil {
|
if help != nil {
|
||||||
parts := strings.Split(help[i], "\n")
|
parts := strings.Split(help[i], "\n")
|
||||||
for _, part := range parts {
|
lines = append(lines, parts...)
|
||||||
fmt.Printf(" * %s\n", part)
|
}
|
||||||
|
lines = append(lines, fmt.Sprintf("%q", text))
|
||||||
|
pos := i + 1
|
||||||
|
if len(lines) == 1 {
|
||||||
|
fmt.Printf("%2d > %s\n", pos, text)
|
||||||
|
} else {
|
||||||
|
mid := (len(lines) - 1) / 2
|
||||||
|
for i, line := range lines {
|
||||||
|
var sep rune
|
||||||
|
switch i {
|
||||||
|
case 0:
|
||||||
|
sep = '/'
|
||||||
|
case len(lines) - 1:
|
||||||
|
sep = '\\'
|
||||||
|
default:
|
||||||
|
sep = '|'
|
||||||
|
}
|
||||||
|
number := " "
|
||||||
|
if i == mid {
|
||||||
|
number = fmt.Sprintf("%2d", pos)
|
||||||
|
}
|
||||||
|
fmt.Printf("%s %c %s\n", number, sep, line)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fmt.Printf("%2d) %s\n", i+1, text)
|
|
||||||
}
|
}
|
||||||
for {
|
for {
|
||||||
fmt.Printf("%s> ", what)
|
fmt.Printf("%s> ", what)
|
||||||
|
|
Loading…
Reference in a new issue