Hunter0x7c7
2022-08-11 b8230139fb40edea387617b6accd8371e37eda58
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
package all
 
import (
    "github.com/v2fly/v2ray-core/v5/main/commands/base"
)
 
var docFormat = &base.Command{
    UsageLine: "{{.Exec}} format-loader",
    Short:     "config formats and loading",
    Long: `
{{.Exec}} is equipped with multiple loaders to support different 
config formats:
 
    * auto
      The default loader, supports all formats listed below, with 
      format detecting, and mixed fomats support.
 
    * json (.json, .jsonc)
      The json loader, multiple files support, mergeable.
 
    * toml (.toml)
      The toml loader, multiple files support, mergeable.
 
    * yaml (.yml, .yaml)
      The yaml loader, multiple files support, mergeable.
 
    * protobuf / pb (.pb)
      Single file support, unmergeable.
 
 
The following explains how format loaders behaves.
 
Examples:
 
    {{.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.
`,
}