forked from extern/nushell
Fix Linux
This commit is contained in:
parent
3ca0e2bf0c
commit
9d8bb48d3f
@ -49,7 +49,8 @@ fn main() -> Result<(), Box<Error>> {
|
|||||||
let h = crate::shell::Helper::new();
|
let h = crate::shell::Helper::new();
|
||||||
let mut rl: Editor<crate::shell::Helper> = Editor::with_config(config);
|
let mut rl: Editor<crate::shell::Helper> = Editor::with_config(config);
|
||||||
|
|
||||||
if cfg!(windows) {
|
#[cfg(windows)]
|
||||||
|
{
|
||||||
let _ = ansi_term::enable_ansi_support();
|
let _ = ansi_term::enable_ansi_support();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -54,6 +54,8 @@ pub enum Value {
|
|||||||
Primitive(Primitive),
|
Primitive(Primitive),
|
||||||
Object(crate::object::Dictionary),
|
Object(crate::object::Dictionary),
|
||||||
List(Vec<Value>),
|
List(Vec<Value>),
|
||||||
|
|
||||||
|
#[allow(unused)]
|
||||||
Error(Box<ShellError>),
|
Error(Box<ShellError>),
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -149,11 +151,11 @@ impl Value {
|
|||||||
Value::Primitive(Primitive::Boolean(s.into()))
|
Value::Primitive(Primitive::Boolean(s.into()))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(unused)]
|
|
||||||
crate fn system_date(s: SystemTime) -> Value {
|
crate fn system_date(s: SystemTime) -> Value {
|
||||||
Value::Primitive(Primitive::Date(s.into()))
|
Value::Primitive(Primitive::Date(s.into()))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(unused)]
|
||||||
crate fn system_date_result(s: Result<SystemTime, std::io::Error>) -> Value {
|
crate fn system_date_result(s: Result<SystemTime, std::io::Error>) -> Value {
|
||||||
match s {
|
match s {
|
||||||
Ok(time) => Value::Primitive(Primitive::Date(time.into())),
|
Ok(time) => Value::Primitive(Primitive::Date(time.into())),
|
||||||
|
@ -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("size", Value::bytes(metadata.len() as u128));
|
||||||
|
|
||||||
dict.add("created", Value::system_date_result(metadata.created()));
|
match metadata.created() {
|
||||||
dict.add("accessed", Value::system_date_result(metadata.accessed()));
|
Ok(c) => dict.add("created", Value::system_date(c)),
|
||||||
dict.add("modified", Value::system_date_result(metadata.modified()));
|
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)
|
Ok(dict)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user