mirror of
https://github.com/nushell/nushell.git
synced 2024-12-22 15:13:01 +01:00
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 mut rl: Editor<crate::shell::Helper> = Editor::with_config(config);
|
||||
|
||||
if cfg!(windows) {
|
||||
#[cfg(windows)]
|
||||
{
|
||||
let _ = ansi_term::enable_ansi_support();
|
||||
}
|
||||
|
||||
|
@ -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())),
|
||||
|
@ -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)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user