forked from extern/nushell
revert file_types to lowercase (#623)
* revert file_types to lowercase * fix test
This commit is contained in:
parent
7d1d6f075c
commit
7faa4fbff4
@ -217,24 +217,24 @@ use std::path::{Path, PathBuf};
|
|||||||
|
|
||||||
pub fn get_file_type(md: &std::fs::Metadata) -> &str {
|
pub fn get_file_type(md: &std::fs::Metadata) -> &str {
|
||||||
let ft = md.file_type();
|
let ft = md.file_type();
|
||||||
let mut file_type = "Unknown";
|
let mut file_type = "unknown";
|
||||||
if ft.is_dir() {
|
if ft.is_dir() {
|
||||||
file_type = "Dir";
|
file_type = "dir";
|
||||||
} else if ft.is_file() {
|
} else if ft.is_file() {
|
||||||
file_type = "File";
|
file_type = "file";
|
||||||
} else if ft.is_symlink() {
|
} else if ft.is_symlink() {
|
||||||
file_type = "Symlink";
|
file_type = "symlink";
|
||||||
} else {
|
} else {
|
||||||
#[cfg(unix)]
|
#[cfg(unix)]
|
||||||
{
|
{
|
||||||
if ft.is_block_device() {
|
if ft.is_block_device() {
|
||||||
file_type = "Block device";
|
file_type = "block device";
|
||||||
} else if ft.is_char_device() {
|
} else if ft.is_char_device() {
|
||||||
file_type = "Char device";
|
file_type = "char device";
|
||||||
} else if ft.is_fifo() {
|
} else if ft.is_fifo() {
|
||||||
file_type = "Pipe";
|
file_type = "pipe";
|
||||||
} else if ft.is_socket() {
|
} else if ft.is_socket() {
|
||||||
file_type = "Socket";
|
file_type = "socket";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -59,7 +59,7 @@ impl Command for SubCommand {
|
|||||||
Example {
|
Example {
|
||||||
description: "Show type of a filepath",
|
description: "Show type of a filepath",
|
||||||
example: "'.' | path type",
|
example: "'.' | path type",
|
||||||
result: Some(Value::test_string("Dir")),
|
result: Some(Value::test_string("dir")),
|
||||||
},
|
},
|
||||||
Example {
|
Example {
|
||||||
description: "Show type of a filepath in a column",
|
description: "Show type of a filepath in a column",
|
||||||
@ -84,25 +84,25 @@ fn r#type(path: &Path, span: Span, _: &Arguments) -> Value {
|
|||||||
|
|
||||||
fn get_file_type(md: &std::fs::Metadata) -> &str {
|
fn get_file_type(md: &std::fs::Metadata) -> &str {
|
||||||
let ft = md.file_type();
|
let ft = md.file_type();
|
||||||
let mut file_type = "Unknown";
|
let mut file_type = "unknown";
|
||||||
if ft.is_dir() {
|
if ft.is_dir() {
|
||||||
file_type = "Dir";
|
file_type = "dir";
|
||||||
} else if ft.is_file() {
|
} else if ft.is_file() {
|
||||||
file_type = "File";
|
file_type = "file";
|
||||||
} else if ft.is_symlink() {
|
} else if ft.is_symlink() {
|
||||||
file_type = "Symlink";
|
file_type = "symlink";
|
||||||
} else {
|
} else {
|
||||||
#[cfg(unix)]
|
#[cfg(unix)]
|
||||||
{
|
{
|
||||||
use std::os::unix::fs::FileTypeExt;
|
use std::os::unix::fs::FileTypeExt;
|
||||||
if ft.is_block_device() {
|
if ft.is_block_device() {
|
||||||
file_type = "Block device";
|
file_type = "block device";
|
||||||
} else if ft.is_char_device() {
|
} else if ft.is_char_device() {
|
||||||
file_type = "Char device";
|
file_type = "char device";
|
||||||
} else if ft.is_fifo() {
|
} else if ft.is_fifo() {
|
||||||
file_type = "Pipe";
|
file_type = "pipe";
|
||||||
} else if ft.is_socket() {
|
} else if ft.is_socket() {
|
||||||
file_type = "Socket";
|
file_type = "socket";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user