Skip to content

Commit 9cab4d9

Browse files
committed
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.
1 parent 6d6f2c6 commit 9cab4d9

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

cli/src/commands/config/set.rs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,15 @@ pub struct ConfigSetArgs {
3838
/// New value to set
3939
///
4040
/// The value should be specified as a TOML expression. If string value
41-
/// doesn't contain any TOML constructs (such as array notation), quotes can
42-
/// be omitted.
41+
/// doesn't contain any TOML constructs (such as apostrophes or array
42+
/// notation), quotes can be omitted. Note that the value may also need
43+
/// shell quoting. TOML multi-line strings can be useful if the value
44+
/// contains apostrophes. For example, to set `foo.bar` to the string
45+
/// "don't" use `jj config set --user foo.bar "'''don't'''"`. This
46+
/// is valid in both Bash and Fish.
47+
///
48+
/// Alternative, e.g. to avoid dealing with shell quoting, use `jj config
49+
/// edit` to edit the TOML file directly.
4350
#[arg(required = true, value_parser = parse_value_or_bare_string)]
4451
value: ConfigValue,
4552
#[command(flatten)]

cli/tests/[email protected]

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -642,7 +642,9 @@ Update config file to set the given option to a given value
642642
* `<NAME>`
643643
* `<VALUE>` — New value to set
644644

645-
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.
645+
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. TOML multi-line strings can be useful if the value contains apostrophes. For example, to set `foo.bar` to the string "don't" use `jj config set --user foo.bar "'''don't'''"`. This is valid in both Bash and Fish.
646+
647+
Alternative, e.g. to avoid dealing with shell quoting, use `jj config edit` to edit the TOML file directly.
646648

647649
###### **Options:**
648650

0 commit comments

Comments
 (0)