mirror of
https://github.com/rclone/rclone.git
synced 2024-11-30 04:15:26 +01:00
f73ee5eade
These are set in the form RCLONE_CONFIG_remote_option where remote is the uppercased remote name and option is the uppercased config file option name. Note that RCLONE_CONFIG_remote_TYPE must be set if defining a new remote. Fixes #616
50 lines
1.0 KiB
Go
50 lines
1.0 KiB
Go
package ls
|
|
|
|
import (
|
|
"fmt"
|
|
"sort"
|
|
|
|
"github.com/ncw/rclone/cmd"
|
|
"github.com/ncw/rclone/fs"
|
|
"github.com/spf13/cobra"
|
|
)
|
|
|
|
// Globals
|
|
var (
|
|
listLong bool
|
|
)
|
|
|
|
func init() {
|
|
cmd.Root.AddCommand(commandDefintion)
|
|
commandDefintion.Flags().BoolVarP(&listLong, "long", "l", listLong, "Show the type as well as names.")
|
|
}
|
|
|
|
var commandDefintion = &cobra.Command{
|
|
Use: "listremotes",
|
|
Short: `List all the remotes in the config file.`,
|
|
Long: `
|
|
rclone listremotes lists all the available remotes from the config file.
|
|
|
|
When uses with the -l flag it lists the types too.
|
|
`,
|
|
Run: func(command *cobra.Command, args []string) {
|
|
cmd.CheckArgs(0, 0, command, args)
|
|
remotes := fs.ConfigFileSections()
|
|
sort.Strings(remotes)
|
|
maxlen := 1
|
|
for _, remote := range remotes {
|
|
if len(remote) > maxlen {
|
|
maxlen = len(remote)
|
|
}
|
|
}
|
|
for _, remote := range remotes {
|
|
if listLong {
|
|
remoteType := fs.ConfigFileGet(remote, "type", "UNKNOWN")
|
|
fmt.Printf("%-*s %s\n", maxlen+1, remote+":", remoteType)
|
|
} else {
|
|
fmt.Printf("%s:\n", remote)
|
|
}
|
|
}
|
|
},
|
|
}
|