cli: complete: use null Ui to prevent writing warnings into completions

E.g. when the user doesn't have the default command set, you don't want
to get
```
Warning: Cannot define an alias that overrides the built-in command 'log'
```
printed on every completion.
This commit is contained in:
Jakob Hellermann 2025-01-31 21:26:31 +01:00
parent d7c887c424
commit d212becdba
2 changed files with 2 additions and 2 deletions

View File

@ -3714,7 +3714,7 @@ impl CliRunner {
ui.reset(&config)?;
if env::var_os("COMPLETE").is_some() {
return handle_shell_completion(ui, &self.app, &config, &cwd);
return handle_shell_completion(&Ui::null(), &self.app, &config, &cwd);
}
let string_args = expand_args(ui, &self.app, env::args_os(), &config)?;

View File

@ -758,7 +758,7 @@ fn get_jj_command() -> Result<(JjBuilder, UserSettings), CommandError> {
// required.
let app = crate::commands::default_app();
let mut raw_config = config_from_environment(default_config_layers());
let ui = Ui::with_config(raw_config.as_ref()).expect("default config should be valid");
let ui = Ui::null();
let cwd = std::env::current_dir()
.and_then(dunce::canonicalize)
.map_err(user_error)?;