Better handling of config at load
This commit is contained in:
parent
0d57b7a40c
commit
9cba5cfde7
11
src/lib.rs
11
src/lib.rs
@ -426,10 +426,10 @@ pub mod shell {
|
||||
}
|
||||
|
||||
|
||||
fn handle_conf(stdout: &mut Stdout) -> SqishConf {
|
||||
fn handle_conf() -> SqishConf {
|
||||
let conf = match SqishConf::from_sqishrc() {
|
||||
Ok(c) => c,
|
||||
Err(e) => {
|
||||
Err(_) => {
|
||||
let conf = SqishConf {
|
||||
promptline: String::from("!$HISTNUMBER$COLORGREEN_[$USER_@$HOSTNAME_]$COLORRESET_ "),
|
||||
promptline_base: String::from("!$HISTNUMBER_$COLORGREEN_[$USER_@$HOSTNAME_]$COLORRESET_ "),
|
||||
@ -438,9 +438,6 @@ pub mod shell {
|
||||
init: String::new(),
|
||||
env: HashMap::new(),
|
||||
};
|
||||
let ret_line = format!("Could not build conf, got {}\
|
||||
\r\nUsing default promptline", e);
|
||||
write!(stdout, "{}", ret_line);
|
||||
conf
|
||||
},
|
||||
};
|
||||
@ -702,7 +699,7 @@ pub mod shell {
|
||||
max_pos: 0,
|
||||
stdout: stdout().into_raw_mode().unwrap(),
|
||||
current_number: get_curr_history_number(),
|
||||
conf: handle_conf(&mut stdout().into_raw_mode().unwrap()),
|
||||
conf: handle_conf(),
|
||||
};
|
||||
|
||||
let stdin = stdin();
|
||||
@ -719,6 +716,8 @@ pub mod shell {
|
||||
|
||||
if elems.conf.init != String::from("") {
|
||||
run_cmd(&mut String::from(&elems.conf.init), &mut elems.current_number, &mut elems.conf, &mut elems.stdout);
|
||||
} else {
|
||||
run_cmd(&mut String::from(""), &mut elems.current_number, &mut elems.conf, &mut elems.stdout);
|
||||
}
|
||||
|
||||
for c in stdin.keys() {
|
||||
|
Loading…
x
Reference in New Issue
Block a user