fs: Implement RegInfo.FileName to return the on disk filename for a backend

Use it in make_backend_docs.py
This commit is contained in:
Nick Craig-Wood 2018-10-01 21:05:33 +01:00
parent 78b9bd77f5
commit 6b1f915ebc
2 changed files with 6 additions and 8 deletions

View File

@ -10,19 +10,12 @@ marker = "<!--- autogenerated options"
start = marker + " start" start = marker + " start"
stop = marker + " stop" stop = marker + " stop"
# directory name to backend name
dir_to_backend = {
"googlecloudstorage": "google cloud storage",
"amazonclouddrive": "amazon cloud drive",
}
def find_backends(): def find_backends():
"""Return a list of all backends""" """Return a list of all backends"""
return [ x for x in os.listdir("backend") if x not in ("all",) ] return [ x for x in os.listdir("backend") if x not in ("all",) ]
def output_docs(backend, out): def output_docs(backend, out):
"""Output documentation for backend options to out""" """Output documentation for backend options to out"""
backend = dir_to_backend.get(backend, backend)
out.flush() out.flush()
subprocess.check_call(["rclone", "help", "backend", backend], stdout=out) subprocess.check_call(["rclone", "help", "backend", backend], stdout=out)

View File

@ -83,6 +83,11 @@ type RegInfo struct {
Options Options Options Options
} }
// FileName returns the on disk file name for this backend
func (ri *RegInfo) FileName() string {
return strings.Replace(ri.Name, " ", "", -1)
}
// Options is a slice of configuration Option for a backend // Options is a slice of configuration Option for a backend
type Options []Option type Options []Option
@ -871,7 +876,7 @@ type ObjectPair struct {
// Services are looked up in the config file // Services are looked up in the config file
func Find(name string) (*RegInfo, error) { func Find(name string) (*RegInfo, error) {
for _, item := range Registry { for _, item := range Registry {
if item.Name == name || item.Prefix == name { if item.Name == name || item.Prefix == name || item.FileName() == name {
return item, nil return item, nil
} }
} }