From ed95aeb53b67f6864b2b9b6e0465af36b45e2196 Mon Sep 17 00:00:00 2001 From: root Date: Wed, 21 Jan 2026 13:56:21 +0400 Subject: [PATCH] fix: improve error message for invalid config mode --- src/cli/commands.rs | 4 +++- tests/integration_tests.rs | 9 +++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/cli/commands.rs b/src/cli/commands.rs index f128499..38b1f2d 100644 --- a/src/cli/commands.rs +++ b/src/cli/commands.rs @@ -1076,7 +1076,9 @@ fn run_config(action: Option, config: &mut Config) -> Result<()> { Some(ConfigAction::Set { key, value }) => { let result = match key { ConfigKey::Mode => { - let mode: Mode = value.parse()?; + let mode: Mode = value.parse().map_err(|_| { + anyhow::anyhow!("Invalid mode '{}'. Valid values are: server, local", value) + })?; config.set_mode(mode)?; format!("mode = {}", mode) } diff --git a/tests/integration_tests.rs b/tests/integration_tests.rs index efb71d9..ac0c0eb 100644 --- a/tests/integration_tests.rs +++ b/tests/integration_tests.rs @@ -59,3 +59,12 @@ fn test_config_show() { .success() .stdout(predicate::str::contains("Chunk size")); } + +#[test] +fn test_config_set_invalid_mode() { + vgrep() + .args(["config", "set", "mode", "invalid_value"]) + .assert() + .failure() + .stderr(predicate::str::contains("Invalid mode 'invalid_value'. Valid values are: server, local")); +}