forked from TrueCloudLab/rclone
fs: allow backends to have aliases #5616
This allows a backend to have multiple aliases. These aliases are hidden from `rclone config` and the command line flags are hidden from the user. However the flags, environment varialbes and config for the alias will work just fine.
This commit is contained in:
parent
8dc93f1792
commit
c40129d610
2 changed files with 19 additions and 0 deletions
|
@ -576,6 +576,9 @@ func fsOption() *fs.Option {
|
||||||
Required: true,
|
Required: true,
|
||||||
}
|
}
|
||||||
for _, item := range fs.Registry {
|
for _, item := range fs.Registry {
|
||||||
|
if item.Hide {
|
||||||
|
continue
|
||||||
|
}
|
||||||
example := fs.OptionExample{
|
example := fs.OptionExample{
|
||||||
Value: item.Name,
|
Value: item.Name,
|
||||||
Help: item.Description,
|
Help: item.Description,
|
||||||
|
|
|
@ -36,6 +36,10 @@ type RegInfo struct {
|
||||||
Options Options
|
Options Options
|
||||||
// The command help, if any
|
// The command help, if any
|
||||||
CommandHelp []CommandHelp
|
CommandHelp []CommandHelp
|
||||||
|
// Aliases - other names this backend is known by
|
||||||
|
Aliases []string
|
||||||
|
// Hide - if set don't show in the configurator
|
||||||
|
Hide bool
|
||||||
}
|
}
|
||||||
|
|
||||||
// FileName returns the on disk file name for this backend
|
// FileName returns the on disk file name for this backend
|
||||||
|
@ -256,6 +260,18 @@ func Register(info *RegInfo) {
|
||||||
info.Prefix = info.Name
|
info.Prefix = info.Name
|
||||||
}
|
}
|
||||||
Registry = append(Registry, info)
|
Registry = append(Registry, info)
|
||||||
|
for _, alias := range info.Aliases {
|
||||||
|
// Copy the info block and rename and hide the alias and options
|
||||||
|
aliasInfo := *info
|
||||||
|
aliasInfo.Name = alias
|
||||||
|
aliasInfo.Prefix = alias
|
||||||
|
aliasInfo.Hide = true
|
||||||
|
aliasInfo.Options = append(Options(nil), info.Options...)
|
||||||
|
for i := range aliasInfo.Options {
|
||||||
|
aliasInfo.Options[i].Hide = OptionHideBoth
|
||||||
|
}
|
||||||
|
Registry = append(Registry, &aliasInfo)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Find looks for a RegInfo object for the name passed in. The name
|
// Find looks for a RegInfo object for the name passed in. The name
|
||||||
|
|
Loading…
Add table
Reference in a new issue