show a single backend
(name string)
| 280 | |
| 281 | // show a single backend |
| 282 | func showBackend(name string) { |
| 283 | backend, err := fs.Find(name) |
| 284 | if err != nil { |
| 285 | fs.Fatal(nil, fmt.Sprint(err)) |
| 286 | } |
| 287 | var standardOptions, advancedOptions fs.Options |
| 288 | done := map[string]struct{}{} |
| 289 | for _, opt := range backend.Options { |
| 290 | // Skip if done already (e.g. with Provider options) |
| 291 | if _, doneAlready := done[opt.Name]; doneAlready { |
| 292 | continue |
| 293 | } |
| 294 | done[opt.Name] = struct{}{} |
| 295 | if opt.Advanced { |
| 296 | advancedOptions = append(advancedOptions, opt) |
| 297 | } else { |
| 298 | standardOptions = append(standardOptions, opt) |
| 299 | } |
| 300 | } |
| 301 | optionsType := "standard" |
| 302 | for _, opts := range []fs.Options{standardOptions, advancedOptions} { |
| 303 | if len(opts) == 0 { |
| 304 | optionsType = "advanced" |
| 305 | continue |
| 306 | } |
| 307 | optionsType = cases.Title(language.Und, cases.NoLower).String(optionsType) |
| 308 | fmt.Printf("### %s options\n\n", optionsType) |
| 309 | fmt.Printf("Here are the %s options specific to %s (%s).\n\n", optionsType, backend.Name, backend.Description) |
| 310 | optionsType = "advanced" |
| 311 | for _, opt := range opts { |
| 312 | done[opt.Name] = struct{}{} |
| 313 | shortOpt := "" |
| 314 | if opt.ShortOpt != "" { |
| 315 | shortOpt = fmt.Sprintf(" / -%s", opt.ShortOpt) |
| 316 | } |
| 317 | fmt.Printf("#### --%s%s\n\n", opt.FlagName(backend.Prefix), shortOpt) |
| 318 | fmt.Printf("%s\n\n", opt.Help) |
| 319 | if opt.IsPassword { |
| 320 | fmt.Printf("**NB** Input to this must be obscured - see [rclone obscure](/commands/rclone_obscure/).\n\n") |
| 321 | } |
| 322 | fmt.Printf("Properties:\n\n") |
| 323 | fmt.Printf("- Config: %s\n", opt.Name) |
| 324 | fmt.Printf("- Env Var: %s\n", opt.EnvVarName(backend.Prefix)) |
| 325 | if opt.Provider != "" { |
| 326 | fmt.Printf("- Provider: %s\n", opt.Provider) |
| 327 | } |
| 328 | fmt.Printf("- Type: %s\n", opt.Type()) |
| 329 | defaultValue := opt.GetValue() |
| 330 | // Default value and Required are related: Required means option must |
| 331 | // have a value, but if there is a default then a value does not have |
| 332 | // to be explicitly set and then Required makes no difference. |
| 333 | if defaultValue != "" { |
| 334 | fmt.Printf("- Default: %s\n", quoteString(defaultValue)) |
| 335 | } else { |
| 336 | fmt.Printf("- Required: %v\n", opt.Required) |
| 337 | } |
| 338 | // List examples / possible choices |
| 339 | if len(opt.Examples) > 0 { |
no test coverage detected
searching dependent graphs…