forked from mirrors/jj
cli: don't panic on invalid config
If `~/.jjconfig` is invalid, we currently simply panic. That results in a poor error message. We should handle the error instead. Closes #55.
This commit is contained in:
parent
f4cadff6e1
commit
108b785a36
2 changed files with 13 additions and 5 deletions
|
@ -14,7 +14,7 @@
|
|||
|
||||
use std::path::Path;
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
#[derive(Debug, Clone, Default)]
|
||||
pub struct UserSettings {
|
||||
config: config::Config,
|
||||
}
|
||||
|
|
16
src/main.rs
16
src/main.rs
|
@ -20,8 +20,16 @@ fn main() {
|
|||
// TODO: We need to do some argument parsing here, at least for things like
|
||||
// --config, and for reading user configs from the repo pointed to by
|
||||
// -R.
|
||||
let user_settings = UserSettings::for_user().unwrap();
|
||||
let ui = Ui::for_terminal(user_settings);
|
||||
let status = dispatch(ui, &mut std::env::args_os());
|
||||
std::process::exit(status);
|
||||
match UserSettings::for_user() {
|
||||
Ok(user_settings) => {
|
||||
let ui = Ui::for_terminal(user_settings);
|
||||
let status = dispatch(ui, &mut std::env::args_os());
|
||||
std::process::exit(status);
|
||||
}
|
||||
Err(err) => {
|
||||
let mut ui = Ui::for_terminal(UserSettings::default());
|
||||
ui.write_error(&format!("Invalid config: {}\n", err))
|
||||
.unwrap();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue