mirror of
https://github.com/rclone/rclone.git
synced 2024-11-07 09:04:52 +01:00
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
@ -576,6 +576,9 @@ func fsOption() *fs.Option {
|
||||
Required: true,
|
||||
}
|
||||
for _, item := range fs.Registry {
|
||||
if item.Hide {
|
||||
continue
|
||||
}
|
||||
example := fs.OptionExample{
|
||||
Value: item.Name,
|
||||
Help: item.Description,
|
||||
|
@ -36,6 +36,10 @@ type RegInfo struct {
|
||||
Options Options
|
||||
// The command help, if any
|
||||
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
|
||||
@ -256,6 +260,18 @@ func Register(info *RegInfo) {
|
||||
info.Prefix = info.Name
|
||||
}
|
||||
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
|
||||
|
Loading…
Reference in New Issue
Block a user