About the structure of json file
json
{
"root": [],
"options": [],
"common_options": [],
"info": {},
"config": []
}
- The json file uses a schema structure to ensure that the json content is correct and complete.
- You can learn about these properties by hovering over the prompts
- In fact, it is very simple, you can refer to the existing json file.
Properties
1. root
The type of value: array
The most core attribute (usually)
- Each item in the array is an object.
- Object available attribute:
name
(required)、alias
、next
、options
、tip
- In vscode, with schema, it's easy to understand.
- The values of
next
andoptions
are also arrays, almost identical toroot
.- Difference: The
options
attribute is not allowed inoptions
.
- Difference: The
2. options
- The type of value: array
- Same as the
options
for each item inroot
.json{ "options": [ { "name": "--version", "alias": ["-V"], "tip": ["Show current version"] } ] }
3. common_options
- The type of value: array
- Same structure as
options
- All options are displayed at all times.json
{ "common_options": [ { "name": "--help", "alias": ["-h"], "tip": ["Show help."] } ] }
4. info
- The type of value: object
- All values defined can be obtained elsewhere with the following syntax.json
// {{ $info.xxx }} // {{ $json.xxx }} $json is the object of the entire json file. { "root": [ { "name": "test", "tip": "{{ $info.test_tip }}" }, { "name": "abc", "tip": "{{ $json.info.abc_tip }}" } ], "info": { "test_tip": "this is test content.", "abc_tip": "abcdefg" } }
5. config
- The type of value: array
- Define some special configurations for completion.(e.g.
git
)json"config": [ { "name": "max_commit", "value": 20, "values": [ -1, 20 ], "tip": [ "The maximum number that can be parsed for a project commit. Default to 20.\n", "If it is <@Magenta>-1<@Blue>, all commits will be parsed, which may affect the loading speed." ] } ]