1
0
mirror of https://github.com/rclone/rclone.git synced 2026-01-20 09:23:21 +00:00

backend: add description field for all backends

Fixes #4391
This commit is contained in:
Paul Stern
2023-12-02 19:27:55 +03:00
committed by Nick Craig-Wood
parent a3d19942bd
commit bb679a9def
3 changed files with 18 additions and 3 deletions

View File

@@ -19,7 +19,7 @@ var (
func init() {
cmd.Root.AddCommand(commandDefinition)
cmdFlags := commandDefinition.Flags()
flags.BoolVarP(cmdFlags, &listLong, "long", "", listLong, "Show the type as well as names", "")
flags.BoolVarP(cmdFlags, &listLong, "long", "", listLong, "Show the type and the description as well as names", "")
}
var commandDefinition = &cobra.Command{
@@ -28,7 +28,7 @@ var commandDefinition = &cobra.Command{
Long: `
rclone listremotes lists all the available remotes from the config file.
When used with the ` + "`--long`" + ` flag it lists the types too.
When used with the ` + "`--long`" + ` flag it lists the types and the descriptions too.
`,
Annotations: map[string]string{
"versionIntroduced": "v1.34",
@@ -38,15 +38,21 @@ When used with the ` + "`--long`" + ` flag it lists the types too.
remotes := config.FileSections()
sort.Strings(remotes)
maxlen := 1
maxlentype := 1
for _, remote := range remotes {
if len(remote) > maxlen {
maxlen = len(remote)
}
t := config.FileGet(remote, "type")
if len(t) > maxlentype {
maxlentype = len(t)
}
}
for _, remote := range remotes {
if listLong {
remoteType := config.FileGet(remote, "type")
fmt.Printf("%-*s %s\n", maxlen+1, remote+":", remoteType)
description := config.FileGet(remote, "description")
fmt.Printf("%-*s %-*s %s\n", maxlen+1, remote+":", maxlentype+1, remoteType, description)
} else {
fmt.Printf("%s:\n", remote)
}