2020-11-28 09:06:03 -05:00
|
|
|
package all
|
|
|
|
|
|
|
|
import (
|
2022-01-02 10:16:23 -05:00
|
|
|
"github.com/v2fly/v2ray-core/v5/main/commands/base"
|
2020-11-28 09:06:03 -05:00
|
|
|
)
|
|
|
|
|
|
|
|
var docFormat = &base.Command{
|
|
|
|
UsageLine: "{{.Exec}} format-loader",
|
|
|
|
Short: "config formats and loading",
|
|
|
|
Long: `
|
2021-03-10 16:03:26 -05:00
|
|
|
{{.Exec}} is equipped with multiple loaders to support different
|
|
|
|
config formats:
|
2020-11-28 09:06:03 -05:00
|
|
|
|
2021-02-21 10:02:42 -05:00
|
|
|
* auto
|
2021-03-10 16:03:26 -05:00
|
|
|
The default loader, supports all formats listed below, with
|
|
|
|
format detecting, and mixed fomats support.
|
2021-02-21 10:02:42 -05:00
|
|
|
|
2020-11-28 09:06:03 -05:00
|
|
|
* json (.json, .jsonc)
|
2021-02-21 10:02:42 -05:00
|
|
|
The json loader, multiple files support, mergeable.
|
2021-01-01 09:18:47 -05:00
|
|
|
|
|
|
|
* toml (.toml)
|
2021-02-21 10:02:42 -05:00
|
|
|
The toml loader, multiple files support, mergeable.
|
2020-11-28 09:06:03 -05:00
|
|
|
|
2021-03-10 16:03:26 -05:00
|
|
|
* yaml (.yml, .yaml)
|
2021-02-21 10:02:42 -05:00
|
|
|
The yaml loader, multiple files support, mergeable.
|
2020-11-28 09:06:03 -05:00
|
|
|
|
|
|
|
* protobuf / pb (.pb)
|
2021-02-21 10:02:42 -05:00
|
|
|
Single file support, unmergeable.
|
2020-11-28 09:06:03 -05:00
|
|
|
|
|
|
|
|
2021-03-10 16:03:26 -05:00
|
|
|
The following explains how format loaders behaves.
|
2020-11-28 09:06:03 -05:00
|
|
|
|
|
|
|
Examples:
|
|
|
|
|
2021-02-21 10:02:42 -05:00
|
|
|
{{.Exec}} run -d dir (1)
|
|
|
|
{{.Exec}} run -c c1.json -c c2.yaml (2)
|
|
|
|
{{.Exec}} run -format=json -d dir (3)
|
|
|
|
{{.Exec}} test -c c1.yml -c c2.pb (4)
|
|
|
|
{{.Exec}} test -format=pb -d dir (5)
|
|
|
|
{{.Exec}} test -format=protobuf -c c1.json (6)
|
|
|
|
|
|
|
|
(1) Load all supported files in the "dir".
|
|
|
|
(2) JSON and YAML are merged and loaded.
|
|
|
|
(3) Load all JSON files in the "dir".
|
|
|
|
(4) Goes error since .pb is not mergeable to others
|
|
|
|
(5) Works only when single .pb file found, if not, failed due to
|
|
|
|
unmergeable.
|
|
|
|
(6) Force load "c1.json" as protobuf, no matter its extension.
|
2020-11-28 09:06:03 -05:00
|
|
|
`,
|
|
|
|
}
|