Skip to content

Commit

Permalink
feat(schema): update
Browse files Browse the repository at this point in the history
  • Loading branch information
abgox committed Dec 13, 2024
1 parent 06e783c commit f9ff5e4
Show file tree
Hide file tree
Showing 5 changed files with 659 additions and 8 deletions.
6 changes: 6 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@
"completions/**/config.json"
]
},
{
"url": "/schema/zh-CN/completion-cn.json",
"fileMatch": [
"completions/**/language/zh-CN.json"
]
},
{
"url": "/schema/zh-CN/completion.json",
"fileMatch": [
Expand Down
318 changes: 318 additions & 0 deletions schema/en-US/completion-cn.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,318 @@
{
"$schema": "http://json-schema.org/draft-07/schema",
"description": "The JSON Schema of the the PSCompletions module completion data file.",
"type": "object",
"required": [
"info"
],
"anyOf": [
{
"required": [
"root"
]
},
{
"required": [
"options"
]
},
{
"required": [
"common_options"
]
}
],
"definitions": {
"completion_tip": {
"$ref": "#/definitions/array_items",
"description": "A description of the configuration item.\nMust contain one of the following Chinese symbols.\n。?!;",
"contains": {
"type": "string",
"pattern": ".*[。?!;].*"
}
},
"string": {
"type": "string",
"minLength": 1
},
"array": {
"type": "array",
"minItems": 1,
"uniqueItems": true
},
"array_items": {
"$ref": "#/definitions/array",
"items": {
"type": "string",
"minLength": 1
}
},
"root_item": {
"type": "object",
"required": [
"name"
],
"properties": {
"name": {
"$ref": "#/definitions/string",
"description": "command name"
},
"alias": {
"$ref": "#/definitions/array_items",
"description": "command alias"
},
"symbol": {
"description": "Symbol",
"anyOf": [
{
"$ref": "#/definitions/array",
"description": "It must be an array.",
"enum": [
[]
]
},
{
"$ref": "#/definitions/array",
"description": "When using hooks to dynamically generate some completions, you need to specify SpaceTab.",
"enum": [
[
"SpaceTab"
]
]
},
{
"$ref": "#/definitions/array",
"description": "You can also use PowerShell syntax, which requires {{ }} wraps.",
"enum": [
[
"{{",
"if($true){ 'SpaceTab' }",
"}}"
]
]
},
{
"$ref": "#/definitions/array",
"items": {
"$ref": "#/definitions/string",
"oneOf": [
{
"description": "Specify SpaceTab",
"enum": [
"SpaceTab"
]
},
{}
]
}
}
]
},
"tip": {
"$ref": "#/definitions/completion_tip"
},
"next": {
"type": "array",
"uniqueItems": true,
"description": "Next command completion, it's used to define the completion that can be obtained after entering the command by pressing the Tab key",
"items": {
"$ref": "#/definitions/root_item"
}
},
"options": {
"type": "array",
"uniqueItems": true,
"description": "Available option completion",
"items": {
"$ref": "#/definitions/options_item"
}
}
},
"additionalProperties": false
},
"options_item": {
"type": "object",
"required": [
"name"
],
"properties": {
"name": {
"$ref": "#/definitions/string",
"description": "command name"
},
"alias": {
"$ref": "#/definitions/array_items",
"description": "command alias"
},
"symbol": {
"description": "Symbol.(OptionTab is added by default)",
"anyOf": [
{
"$ref": "#/definitions/array",
"description": "It must be an array.",
"enum": [
[]
]
},
{
"$ref": "#/definitions/array",
"description": "Specify Symbol",
"enum": [
[
"WriteSpaceTab"
],
[
"SpaceTab"
]
]
},
{
"$ref": "#/definitions/array",
"description": "You can also use PowerShell syntax, which requires {{ }} wraps.",
"enum": [
[
"{{",
"if($true){'WriteSpaceTab'}",
"}}"
]
]
},
{
"$ref": "#/definitions/array",
"items": {
"$ref": "#/definitions/string",
"anyOf": [
{
"description": "Specify WriteSpaceTab",
"enum": [
"WriteSpaceTab"
]
},
{
"description": "Specify SpaceTab",
"enum": [
"SpaceTab"
]
},
{}
]
}
}
]
},
"tip": {
"$ref": "#/definitions/completion_tip"
},
"next": {
"type": "array",
"uniqueItems": true,
"description": "Next command completion, it's used to define the completion that can be obtained after entering the command by pressing the Tab key.\nIf next is added, WriteSpaceTab is automatically added to the symbol of the current.",
"items": {
"$ref": "#/definitions/root_item"
}
}
},
"additionalProperties": false
}
},
"properties": {
"root": {
"$ref": "#/definitions/array",
"description": "The root node of the command",
"items": {
"$ref": "#/definitions/root_item"
}
},
"options": {
"$ref": "#/definitions/array",
"description": "Optional Completion\nfor the root command",
"items": {
"$ref": "#/definitions/options_item"
}
},
"common_options": {
"$ref": "#/definitions/array",
"description": "General Optional Completion\nSome general options, these options will appear in any situation",
"items": {
"$ref": "#/definitions/options_item"
}
},
"info": {
"description": "Some completion information, which can be accessed using {{ $info.xxx }} in any place in this json file",
"type": "object",
"minProperties": 1,
"required": [
"completion_info"
],
"properties": {
"completion_info": {
"type": "object",
"description": "Some information about completion.",
"required": [
"url",
"description"
],
"properties": {
"url": {
"$ref": "#/definitions/string",
"description": "The homepage of the command."
},
"description": {
"$ref": "#/definitions/array_items",
"description": "The description of the command."
}
},
"additionalProperties": false
}
}
},
"config": {
"description": "Some special configuration items are defined here.",
"type": "array",
"items": {
"type": "object",
"required": [
"name",
"value",
"tip"
],
"properties": {
"name": {
"$ref": "#/definitions/string",
"description": "A name for the configuration item"
},
"value": {
"oneOf": [
{
"$ref": "#/definitions/string"
},
{
"type": "number"
}
],
"description": "A default value for the configuration item"
},
"values": {
"$ref": "#/definitions/array",
"items": {
"oneOf": [
{
"$ref": "#/definitions/string"
},
{
"type": "number"
}
]
},
"description": "A list of possible values that will be displayed in the completion of the completion command"
},
"tip": {
"$ref": "#/definitions/array_items",
"description": "A description of the configuration item"
}
}
}
}
},
"additionalProperties": false
}
13 changes: 9 additions & 4 deletions schema/en-US/completion.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,13 @@
}
],
"definitions": {
"completion_tip": {
"$ref": "#/definitions/array_items"
// "description": "A description of the configuration item.\nMust contain one of the following Chinese symbols.\n.?!;",
// "contains": {
// "pattern": ".*[\\.?!;].*"
// }
},
"string": {
"type": "string",
"minLength": 1
Expand Down Expand Up @@ -101,8 +108,7 @@
]
},
"tip": {
"$ref": "#/definitions/array_items",
"description": "Completion tip"
"$ref": "#/definitions/completion_tip"
},
"next": {
"type": "array",
Expand Down Expand Up @@ -194,8 +200,7 @@
]
},
"tip": {
"$ref": "#/definitions/array_items",
"description": "Completion tip"
"$ref": "#/definitions/completion_tip"
},
"next": {
"type": "array",
Expand Down
Loading

0 comments on commit f9ff5e4

Please sign in to comment.