forked from TrueCloudLab/rclone
parent
a3d19942bd
commit
bb679a9def
3 changed files with 18 additions and 3 deletions
|
@ -19,7 +19,7 @@ var (
|
||||||
func init() {
|
func init() {
|
||||||
cmd.Root.AddCommand(commandDefinition)
|
cmd.Root.AddCommand(commandDefinition)
|
||||||
cmdFlags := commandDefinition.Flags()
|
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{
|
var commandDefinition = &cobra.Command{
|
||||||
|
@ -28,7 +28,7 @@ var commandDefinition = &cobra.Command{
|
||||||
Long: `
|
Long: `
|
||||||
rclone listremotes lists all the available remotes from the config file.
|
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{
|
Annotations: map[string]string{
|
||||||
"versionIntroduced": "v1.34",
|
"versionIntroduced": "v1.34",
|
||||||
|
@ -38,15 +38,21 @@ When used with the ` + "`--long`" + ` flag it lists the types too.
|
||||||
remotes := config.FileSections()
|
remotes := config.FileSections()
|
||||||
sort.Strings(remotes)
|
sort.Strings(remotes)
|
||||||
maxlen := 1
|
maxlen := 1
|
||||||
|
maxlentype := 1
|
||||||
for _, remote := range remotes {
|
for _, remote := range remotes {
|
||||||
if len(remote) > maxlen {
|
if len(remote) > maxlen {
|
||||||
maxlen = len(remote)
|
maxlen = len(remote)
|
||||||
}
|
}
|
||||||
|
t := config.FileGet(remote, "type")
|
||||||
|
if len(t) > maxlentype {
|
||||||
|
maxlentype = len(t)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
for _, remote := range remotes {
|
for _, remote := range remotes {
|
||||||
if listLong {
|
if listLong {
|
||||||
remoteType := config.FileGet(remote, "type")
|
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 {
|
} else {
|
||||||
fmt.Printf("%s:\n", remote)
|
fmt.Printf("%s:\n", remote)
|
||||||
}
|
}
|
||||||
|
|
|
@ -104,6 +104,7 @@ func TestCRUD(t *testing.T) {
|
||||||
"y", // type my own password
|
"y", // type my own password
|
||||||
"secret", // password
|
"secret", // password
|
||||||
"secret", // repeat
|
"secret", // repeat
|
||||||
|
"n", // don't edit advanced config
|
||||||
"y", // looks good, save
|
"y", // looks good, save
|
||||||
})
|
})
|
||||||
require.NoError(t, config.NewRemote(ctx, "test"))
|
require.NoError(t, config.NewRemote(ctx, "test"))
|
||||||
|
|
|
@ -19,6 +19,13 @@ import (
|
||||||
// Registry of filesystems
|
// Registry of filesystems
|
||||||
var Registry []*RegInfo
|
var Registry []*RegInfo
|
||||||
|
|
||||||
|
// optDescription is a basic description option
|
||||||
|
var optDescription = Option{
|
||||||
|
Name: "description",
|
||||||
|
Help: "Description of the remote",
|
||||||
|
Advanced: true,
|
||||||
|
}
|
||||||
|
|
||||||
// RegInfo provides information about a filesystem
|
// RegInfo provides information about a filesystem
|
||||||
type RegInfo struct {
|
type RegInfo struct {
|
||||||
// Name of this fs
|
// Name of this fs
|
||||||
|
@ -283,6 +290,7 @@ func Register(info *RegInfo) {
|
||||||
if info.Prefix == "" {
|
if info.Prefix == "" {
|
||||||
info.Prefix = info.Name
|
info.Prefix = info.Name
|
||||||
}
|
}
|
||||||
|
info.Options = append(info.Options, optDescription)
|
||||||
Registry = append(Registry, info)
|
Registry = append(Registry, info)
|
||||||
for _, alias := range info.Aliases {
|
for _, alias := range info.Aliases {
|
||||||
// Copy the info block and rename and hide the alias and options
|
// Copy the info block and rename and hide the alias and options
|
||||||
|
|
Loading…
Reference in a new issue