From f5fb73cda15b2be59e8395da12c049af95fed237 Mon Sep 17 00:00:00 2001 From: Martin von Zweigbergk Date: Fri, 7 Feb 2025 13:16:34 -0800 Subject: [PATCH] cli: describe how to set a config value with apostrophes Apostrophes are not uncommon in e.g. `user.name`, so let's help the user by providing examples. --- cli/src/commands/config/set.rs | 9 +++++++-- cli/tests/cli-reference@.md.snap | 2 +- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/cli/src/commands/config/set.rs b/cli/src/commands/config/set.rs index 299506f62f..2176659187 100644 --- a/cli/src/commands/config/set.rs +++ b/cli/src/commands/config/set.rs @@ -38,8 +38,13 @@ pub struct ConfigSetArgs { /// New value to set /// /// The value should be specified as a TOML expression. If string value - /// doesn't contain any TOML constructs (such as array notation), quotes can - /// be omitted. + /// doesn't contain any TOML constructs (such as apostrophes or array + /// notation), quotes can be omitted. Note that the value may also need + /// shell quoting. The exact syntax depends on your shell. For example, + /// to set `foo.bar` to the string "don't" in Bash, use + /// `jj config set --user foo.bar '"don'\''t"'`. In Fish, use + /// `jj config set --user foo.bar '"don\'t"'`. Alternatively, use + /// `jj config edit` to edit the TOML file directly. #[arg(required = true, value_parser = parse_value_or_bare_string)] value: ConfigValue, #[command(flatten)] diff --git a/cli/tests/cli-reference@.md.snap b/cli/tests/cli-reference@.md.snap index 5791a09ec5..b9386116b3 100644 --- a/cli/tests/cli-reference@.md.snap +++ b/cli/tests/cli-reference@.md.snap @@ -642,7 +642,7 @@ Update config file to set the given option to a given value * `` * `` — New value to set - The value should be specified as a TOML expression. If string value doesn't contain any TOML constructs (such as array notation), quotes can be omitted. + The value should be specified as a TOML expression. If string value doesn't contain any TOML constructs (such as apostrophes or array notation), quotes can be omitted. Note that the value may also need shell quoting. The exact syntax depends on your shell. For example, to set `foo.bar` to the string "don't" in Bash, use `jj config set --user foo.bar '"don'\''t"'`. In Fish, use `jj config set --user foo.bar '"don\'t"'`. Alternatively, use `jj config edit` to edit the TOML file directly. ###### **Options:**