Skip to content

Commit f87c6ed

Browse files
committed
cli: deprecate --config-toml
Typical usage should now be covered by --config=NAME=VALUE. Closes #3867
1 parent abf4857 commit f87c6ed

File tree

6 files changed

+32
-23
lines changed

6 files changed

+32
-23
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@ to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
3636

3737
### Deprecations
3838

39+
* `--config-toml=TOML` is deprecated in favor of `--config=NAME=VALUE` and
40+
`--config-file=PATH`.
41+
3942
* The `Signature.username()` template method is deprecated for
4043
`Signature().email().local()`.
4144

cli/src/cli_util.rs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3109,8 +3109,9 @@ pub struct EarlyArgs {
31093109
/// constructs (such as array notation), quotes can be omitted.
31103110
#[arg(long, value_name = "NAME=VALUE", global = true)]
31113111
pub config: Vec<String>,
3112-
/// Additional configuration options (can be repeated)
3113-
#[arg(long, value_name = "TOML", global = true)]
3112+
/// Additional configuration options (can be repeated) (DEPRECATED)
3113+
// TODO: delete --config-toml in jj 0.31+
3114+
#[arg(long, value_name = "TOML", global = true, hide = true)]
31143115
pub config_toml: Vec<String>,
31153116
/// Additional configuration files (can be repeated)
31163117
#[arg(long, value_name = "PATH", global = true, value_hint = clap::ValueHint::FilePath)]
@@ -3334,6 +3335,12 @@ fn handle_early_args(
33343335
let args = EarlyArgs::from_arg_matches(&early_matches).unwrap();
33353336

33363337
let old_layers_len = config.layers().len();
3338+
if !args.config_toml.is_empty() {
3339+
writeln!(
3340+
ui.warning_default(),
3341+
"--config-toml is deprecated; use --config or --config-file instead."
3342+
)?;
3343+
}
33373344
config.extend_layers(parse_config_args(&args.merged_config_args(&early_matches))?);
33383345

33393346
// Command arguments overrides any other configuration including the

cli/tests/[email protected]

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,6 @@ To get started, see the tutorial at https://martinvonz.github.io/jj/latest/tutor
197197
* `--config <NAME=VALUE>` — Additional configuration options (can be repeated)
198198
199199
The name should be specified as TOML dotted keys. 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.
200-
* `--config-toml <TOML>` — Additional configuration options (can be repeated)
201200
* `--config-file <PATH>` — Additional configuration files (can be repeated)
202201
203202

cli/tests/test_completion.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,6 @@ fn test_bookmark_names() {
8383
--quiet Silence non-primary command output
8484
--no-pager Disable the pager
8585
--config Additional configuration options (can be repeated)
86-
--config-toml Additional configuration options (can be repeated)
8786
--config-file Additional configuration files (can be repeated)
8887
--help Print help (see more with '--help')
8988
");

cli/tests/test_global_opts.rs

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -591,10 +591,12 @@ fn test_early_args() {
591591
fn test_config_args() {
592592
let test_env = TestEnvironment::default();
593593
let list_config = |args: &[&str]| {
594-
test_env.jj_cmd_success(
594+
// Suppress deprecation warning of --config-toml
595+
let (stdout, _stderr) = test_env.jj_cmd_ok(
595596
test_env.env_root(),
596597
&[&["config", "list", "--include-overridden", "test"], args].concat(),
597-
)
598+
);
599+
stdout
598600
};
599601

600602
std::fs::write(
@@ -649,6 +651,15 @@ fn test_config_args() {
649651
test.key3 = 'file2'
650652
"##);
651653

654+
let (stdout, stderr) = test_env.jj_cmd_ok(
655+
test_env.env_root(),
656+
&["config", "list", "foo", "--config-toml=foo='bar'"],
657+
);
658+
insta::assert_snapshot!(stdout, @"foo = 'bar'");
659+
insta::assert_snapshot!(
660+
stderr,
661+
@"Warning: --config-toml is deprecated; use --config or --config-file instead.");
662+
652663
let stderr = test_env.jj_cmd_failure(test_env.env_root(), &["config", "list", "--config=foo"]);
653664
insta::assert_snapshot!(stderr, @r"
654665
Config error: --config must be specified as NAME=VALUE
@@ -783,7 +794,6 @@ fn test_help() {
783794
--quiet Silence non-primary command output
784795
--no-pager Disable the pager
785796
--config <NAME=VALUE> Additional configuration options (can be repeated)
786-
--config-toml <TOML> Additional configuration options (can be repeated)
787797
--config-file <PATH> Additional configuration files (can be repeated)
788798
");
789799
}

docs/config.md

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1203,27 +1203,18 @@ env JJ_CONFIG=/dev/null jj log # Ignores any settings specified in the con
12031203

12041204
### Specifying config on the command-line
12051205

1206-
You can use one or more `--config`/`--config-toml`/`--config-file` options on
1207-
the command line to specify additional configuration settings. This overrides
1208-
settings defined in config files or environment variables. For example,
1206+
You can use one or more `--config`/`--config-file` options on the command line
1207+
to specify additional configuration settings. This overrides settings defined in
1208+
config files or environment variables. For example,
12091209

12101210
```shell
1211-
jj --config=ui.color=always --config-toml='ui.diff-editor="kdiff3"' split
1211+
jj --config=ui.color=always --config=ui.diff-editor=kdiff3 split
12121212
```
12131213

1214-
Config specified by `--config-toml` must be valid TOML. In particular, string
1215-
values must be surrounded by quotes. To pass these quotes to `jj`, most shells
1216-
require surrounding those quotes with single quotes as shown above. On the other
1217-
hand, `--config` can accept a bare string value.
1214+
Config value should be specified as a TOML expression. If string value doesn't
1215+
contain any TOML constructs (such as array notation), quotes can be omitted.
12181216

1219-
In `sh`-compatible shells, `--config-toml` can be used to merge entire TOML
1220-
files with the config specified in `.jjconfig.toml`:
1221-
1222-
```shell
1223-
jj --config-toml="$(cat extra-config.toml)" log
1224-
```
1225-
1226-
This is equivalent to
1217+
To load an entire TOML document, use `--config-file`:
12271218

12281219
```shell
12291220
jj --config-file=extra-config.toml log

0 commit comments

Comments
 (0)