diff --git a/cli/src/config-schema.json b/cli/src/config-schema.json index 53dd09dac..d7811c4c0 100644 --- a/cli/src/config-schema.json +++ b/cli/src/config-schema.json @@ -47,6 +47,13 @@ ], "default": "diff" }, + "command": { + "type": ["string", "array"], + "minItems": 1, + "items": { + "type": "string" + } + }, "command-env": { "type": "object", "properties": { @@ -108,23 +115,16 @@ "default": "auto" }, "pager": { + "description": "Pager to use for displaying command output", + "default": "less -FRX", "oneOf": [ { - "type": "string" - }, - { - "type": "array", - "minItems": 1, - "items": { - "type": "string" - } + "$ref": "#/properties/ui/definitions/command" }, { "$ref": "#/properties/ui/definitions/command-env" } - ], - "description": "Pager to use for displaying command output", - "default": "less -FRX" + ] }, "streampager": { "type": "object", @@ -169,12 +169,15 @@ "default": "color-words" }, "tool": { - "type": ["array", "string"], - "minItems": 1, - "items": { - "type": "string" - }, - "description": "External tool for generating diffs" + "description": "External tool for generating diffs", + "oneOf": [ + { + "$ref": "#/properties/ui/definitions/command" + }, + { + "$ref": "#/properties/ui/definitions/command-env" + } + ] } } }, @@ -210,26 +213,25 @@ "default": true }, "editor": { - "type": ["array", "string"], - "minItems": 1, - "items": { - "type": "string" - }, - "description": "Editor to use for commands that involve editing text" + "description": "Editor to use for commands that involve editing text", + "oneOf": [ + { + "$ref": "#/properties/ui/definitions/command" + }, + { + "$ref": "#/properties/ui/definitions/command-env" + } + ] }, "diff-editor": { "description": "Editor tool to use for editing diffs", "default": ":builtin", "oneOf": [ { - "type": "string" + "$ref": "#/properties/ui/definitions/command" }, { - "type": "array", - "minItems": 1, - "items": { - "type": "string" - } + "$ref": "#/properties/ui/definitions/command-env" } ] }, @@ -238,14 +240,10 @@ "default": ":builtin", "oneOf": [ { - "type": "string" + "$ref": "#/properties/ui/definitions/command" }, { - "type": "array", - "minItems": 1, - "items": { - "type": "string" - } + "$ref": "#/properties/ui/definitions/command-env" } ] }, @@ -752,12 +750,15 @@ "description": "Settings for how specific filesets are affected by a tool", "properties": { "command": { - "type": "array", - "minItems": 1, - "items": { - "type": "string" - }, - "description": "Arguments used to execute this tool" + "description": "Arguments used to execute this tool", + "oneOf": [ + { + "$ref": "#/properties/ui/definitions/command" + }, + { + "$ref": "#/properties/ui/definitions/command-env" + } + ] }, "patterns": { "type": "array", diff --git a/cli/tests/sample-configs/valid/fix.tools.command_command-env.toml b/cli/tests/sample-configs/valid/fix.tools.command_command-env.toml new file mode 100644 index 000000000..cc2055b74 --- /dev/null +++ b/cli/tests/sample-configs/valid/fix.tools.command_command-env.toml @@ -0,0 +1,8 @@ +#:schema ../../../src/config-schema.json +[fix.tools.clang-format.command] +command = [ + "/usr/bin/clang-format", + "--sort-includes", + "--assume-filename=$path", +] +env = { NO_COLOR = 1 } diff --git a/cli/tests/sample-configs/valid/fix.tools.command_string.toml b/cli/tests/sample-configs/valid/fix.tools.command_string.toml new file mode 100644 index 000000000..8ee6c849b --- /dev/null +++ b/cli/tests/sample-configs/valid/fix.tools.command_string.toml @@ -0,0 +1,3 @@ +#:schema ../../../src/config-schema.json +[fix.tools.clang-format] +command = "/usr/bin/clang-format" diff --git a/cli/tests/sample-configs/valid/ui_command-env.toml b/cli/tests/sample-configs/valid/ui_command-env.toml new file mode 100644 index 000000000..25140cff2 --- /dev/null +++ b/cli/tests/sample-configs/valid/ui_command-env.toml @@ -0,0 +1,15 @@ +#:schema ../../../src/config-schema.json +[ui] +editor = { command = ["C:/Program Files/Notepad++/notepad++.exe", "-multiInst", "-notabbar", "-nosession", "-noPlugin"], env = {} } + +[ui.diff-editor] +command = ["diffedit3", "$left", "$right"] +env = { RUST_LOG = "poem=debug" } + +[ui.merge-editor] +command = ["diffedit3", "$left", "$base", "$right"] +env = { RUST_LOG = "poem=debug" } + +[ui.diff.tool] +command = ["difft", "--color=always", "$left", "$right"] +env = { DFT_BACKGROUND = "light" }