mirror of
https://github.com/rclone/rclone.git
synced 2026-01-20 09:23:21 +00:00
committed by
Nick Craig-Wood
parent
a3d19942bd
commit
bb679a9def
@@ -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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user