format_doc.go 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. package all
  2. import (
  3. "github.com/v2fly/v2ray-core/v4/main/commands/base"
  4. )
  5. var docFormat = &base.Command{
  6. UsageLine: "{{.Exec}} format-loader",
  7. Short: "config formats and loading",
  8. Long: `
  9. {{.Exec}} supports different config formats:
  10. * json (.json, .jsonc)
  11. The default loader, multiple config files support.
  12. * toml (.toml)
  13. The toml loader, multiple config files support.
  14. * yaml (.yml)
  15. The yaml loader, multiple config files support.
  16. * protobuf / pb (.pb)
  17. Single conifg file support. If multiple files assigned,
  18. only the first one is loaded.
  19. If "-format" is not explicitly specified, {{.Exec}} will choose
  20. a loader by detecting the extension of the first config file, or
  21. use the default loader.
  22. The following explains how format loaders behave with examples.
  23. Examples:
  24. {{.Exec}} run -d dir (1)
  25. {{.Exec}} run -format=protobuf -d dir (2)
  26. {{.Exec}} test -c c1.yml -d dir (3)
  27. {{.Exec}} test -format=pb -c c1.json (4)
  28. (1) The default json loader is used, {{.Exec}} will try to load all
  29. json files in the "dir".
  30. (2) The protobuf loader is specified, {{.Exec}} will try to find
  31. all protobuf files in the "dir", but only the the first
  32. .pb file is loaded.
  33. (3) The yaml loader is selected because of the "c1.yml" file,
  34. {{.Exec}} will try to load "c1.yml" and all yaml files in
  35. the "dir".
  36. (4) The protobuf loader is specified, {{.Exec}} will load
  37. "c1.json" as protobuf, no matter its extension.
  38. `,
  39. }