Fix Linux

This commit is contained in:
Yehuda Katz 2019-05-17 08:30:10 -07:00
parent 3ca0e2bf0c
commit 9d8bb48d3f
3 changed files with 19 additions and 5 deletions

View File

@ -49,7 +49,8 @@ fn main() -> Result<(), Box<Error>> {
let h = crate::shell::Helper::new();
let mut rl: Editor<crate::shell::Helper> = Editor::with_config(config);
if cfg!(windows) {
#[cfg(windows)]
{
let _ = ansi_term::enable_ansi_support();
}

View File

@ -54,6 +54,8 @@ pub enum Value {
Primitive(Primitive),
Object(crate::object::Dictionary),
List(Vec<Value>),
#[allow(unused)]
Error(Box<ShellError>),
}
@ -149,11 +151,11 @@ impl Value {
Value::Primitive(Primitive::Boolean(s.into()))
}
#[allow(unused)]
crate fn system_date(s: SystemTime) -> Value {
Value::Primitive(Primitive::Date(s.into()))
}
#[allow(unused)]
crate fn system_date_result(s: Result<SystemTime, std::io::Error>) -> Value {
match s {
Ok(time) => Value::Primitive(Primitive::Date(time.into())),

View File

@ -32,9 +32,20 @@ crate fn dir_entry_dict(entry: &std::fs::DirEntry) -> Result<Dictionary, ShellEr
dict.add("size", Value::bytes(metadata.len() as u128));
dict.add("created", Value::system_date_result(metadata.created()));
dict.add("accessed", Value::system_date_result(metadata.accessed()));
dict.add("modified", Value::system_date_result(metadata.modified()));
match metadata.created() {
Ok(c) => dict.add("created", Value::system_date(c)),
Err(_) => {}
}
match metadata.accessed() {
Ok(a) => dict.add("accessed", Value::system_date(a)),
Err(_) => {}
}
match metadata.modified() {
Ok(m) => dict.add("modified", Value::system_date(m)),
Err(_) => {}
}
Ok(dict)
}