jj/cli/src
Jonas Greitemann 4a1754bc46 config-schema: deny empty arrays for command-like config options
Anytime an external tool is referenced in the config, the command can be
provided as a string or as a token array. In the latter case, the array
must not be empty; at least the command name must be provided.

The schema didn't previously object to an empty array, though; this has
now been rectified. I've added more sample configs to cover this case.
Those same configs can also be used to illustrate that this is indeed
jj's current behavior:

$ jj --config-file cli/tests/sample-configs/invalid/ui.pager_empty_array.toml show
Config error: Invalid type or value for ui.pager
Caused by: data did not match any variant of untagged enum CommandNameAndArgs
                                                                                                                                                                                  
$ jj --config-file cli/tests/sample-configs/invalid/ui.pager.command_empty_array.toml show
Config error: Invalid type or value for ui.pager
Caused by: data did not match any variant of untagged enum CommandNameAndArgs
                                                                                                                                                                                  
$ jj --config-file cli/tests/sample-configs/invalid/ui.editor_empty_array.toml config edit --user
Config error: Invalid type or value for ui.editor
Caused by: data did not match any variant of untagged enum CommandNameAndArgs
                                                                                                                                                                                  
$ jj --config-file cli/tests/sample-configs/invalid/ui.diff-editor_empty_array.toml split
Error: Failed to load tool configuration
Caused by:
1: Invalid type or value for ui.diff-editor
2: data did not match any variant of untagged enum CommandNameAndArgs
                                                                                                                                                                                  
$ jj --config-file cli/tests/sample-configs/invalid/ui.merge-editor_empty_array.toml resolve
Error: Failed to load tool configuration
Caused by:
1: Invalid type or value for ui.merge-editor
2: data did not match any variant of untagged enum CommandNameAndArgs
                                                                                                                                                                                  
$ jj --config-file cli/tests/sample-configs/invalid/ui.diff.tool_empty_array.toml diff
Config error: Invalid type or value for ui.diff.tool
Caused by: data did not match any variant of untagged enum CommandNameAndArgs
                                                                                                                                                                                  
$ jj --config-file cli/tests/sample-configs/invalid/fix.tools.command_empty_array.toml fix
Config error: Invalid type or value for fix.tools.black
Caused by: data did not match any variant of untagged enum CommandNameAndArgs
in `command`

As a notable exception, `ui.default-command` *is* allowed to be an empty
array. In that case, `jj` will print a usage message. This is also
covered by a valid sample config.
2025-04-24 15:48:08 +00:00
..
commands cli: rebase: consolidate call sites of move_commits() 2025-04-24 13:16:33 +00:00
config cli: add config option for built-in pager's ruler 2025-04-23 03:16:58 +00:00
merge_tools test: introduce test helpers for creating repo path types 2025-04-15 14:42:23 +00:00
cleanup_guard.rs formatting only: switch to Item level import ganularity 2024-08-22 14:52:54 -04:00
cli_util.rs cli: rebase: consolidate call sites of move_commits() 2025-04-24 13:16:33 +00:00
command_error.rs revset: rename StoreError variants to Backend 2025-04-20 02:28:36 +00:00
commit_templater.rs merge: do not map absent tree entry to non-executable 2025-04-13 02:02:58 +00:00
complete.rs cli completion: add completion for jj git push --named 2025-04-01 16:56:33 +00:00
config-schema.json config-schema: deny empty arrays for command-like config options 2025-04-24 15:48:08 +00:00
config.rs config: migrate ui.default-description to template alias 2025-04-21 14:39:47 +00:00
description_util.rs squash: add trailer support 2025-04-18 16:35:16 +00:00
diff_util.rs merge: do not map absent tree entry to non-executable 2025-04-13 02:02:58 +00:00
formatter.rs formatter: add support for reversing colors 2025-03-25 15:54:22 +00:00
generic_templater.rs templater: add config(name) function 2025-01-11 01:40:23 +00:00
git_util.rs git: add deprecation warnings for git.subprocess 2025-04-08 10:36:46 +00:00
graphlog.rs cli: remove GraphLog::Edge type 2025-01-12 01:51:25 +00:00
lib.rs cli: make git support optional 2025-01-08 22:02:21 +00:00
main.rs
movement_util.rs cleanup: enable unused_trait_names clippy lint and run clippy --fix 2025-03-16 00:35:56 +00:00
operation_templater.rs cleanup: enable unused_trait_names clippy lint and run clippy --fix 2025-03-16 00:35:56 +00:00
progress.rs cleanup: remove unneeded lifetime capturing from snapshot_progress() 2025-03-08 01:16:56 +00:00
revset_util.rs revset: extract internal context struct from RevsetParseContext 2025-03-26 13:03:41 +00:00
template.pest templater: rename "logical" eq/ne operators 2024-12-12 22:48:45 +09:00
template_builder.rs cleanup: switch to use<'_> capturing syntax 2025-03-08 01:16:56 +00:00
template_parser.rs cleanup: use new array methods instead of .collect_tuple()/.next_tuple() 2025-04-12 00:58:14 +00:00
templater.rs cleanup: switch to use<'_> capturing syntax 2025-03-08 01:16:56 +00:00
text_util.rs tests: run insta --force-update-snapshots 2025-03-06 21:35:08 +00:00
time_util.rs cleanup: enable unused_trait_names clippy lint and run clippy --fix 2025-03-16 00:35:56 +00:00
ui.rs cli: add config option for built-in pager's ruler 2025-04-23 03:16:58 +00:00