mirror of
https://github.com/Llewellynvdm/exa.git
synced 2025-01-12 00:35:43 +00:00
Add number of hard links column
This is behaviour cribbed from ls. Even though I've never personally used it, I'm sure someone has a use for it.
This commit is contained in:
parent
8839cf4ca5
commit
fc8f8d6c6a
@ -4,6 +4,7 @@ pub enum Column {
|
|||||||
FileSize(bool),
|
FileSize(bool),
|
||||||
User(u64),
|
User(u64),
|
||||||
Group,
|
Group,
|
||||||
|
HardLinks,
|
||||||
}
|
}
|
||||||
|
|
||||||
// Each column can pick its own alignment. Usually, numbers are
|
// Each column can pick its own alignment. Usually, numbers are
|
||||||
@ -17,6 +18,7 @@ impl Column {
|
|||||||
pub fn alignment(&self) -> Alignment {
|
pub fn alignment(&self) -> Alignment {
|
||||||
match *self {
|
match *self {
|
||||||
FileSize(_) => Right,
|
FileSize(_) => Right,
|
||||||
|
HardLinks => Right,
|
||||||
_ => Left,
|
_ => Left,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
3
file.rs
3
file.rs
@ -2,7 +2,7 @@ use colours::{Plain, Style, Black, Red, Green, Yellow, Blue, Purple, Cyan, Fixed
|
|||||||
use std::io::{fs, IoResult};
|
use std::io::{fs, IoResult};
|
||||||
use std::io;
|
use std::io;
|
||||||
|
|
||||||
use column::{Column, Permissions, FileName, FileSize, User, Group};
|
use column::{Column, Permissions, FileName, FileSize, User, Group, HardLinks};
|
||||||
use format::{format_metric_bytes, format_IEC_bytes};
|
use format::{format_metric_bytes, format_IEC_bytes};
|
||||||
use unix::Unix;
|
use unix::Unix;
|
||||||
use sort::SortPart;
|
use sort::SortPart;
|
||||||
@ -94,6 +94,7 @@ impl<'a> File<'a> {
|
|||||||
Permissions => self.permissions_string(),
|
Permissions => self.permissions_string(),
|
||||||
FileName => self.file_name(),
|
FileName => self.file_name(),
|
||||||
FileSize(use_iec) => self.file_size(use_iec),
|
FileSize(use_iec) => self.file_size(use_iec),
|
||||||
|
HardLinks => Red.paint(self.stat.unstable.nlink.to_str().as_slice()),
|
||||||
|
|
||||||
// Display the ID if the user/group doesn't exist, which
|
// Display the ID if the user/group doesn't exist, which
|
||||||
// usually means it was deleted but its files weren't.
|
// usually means it was deleted but its files weren't.
|
||||||
|
16
options.rs
16
options.rs
@ -2,7 +2,7 @@ extern crate getopts;
|
|||||||
|
|
||||||
use file::File;
|
use file::File;
|
||||||
use std::cmp::lexical_ordering;
|
use std::cmp::lexical_ordering;
|
||||||
use column::{Column, Permissions, FileName, FileSize, User, Group};
|
use column::{Column, Permissions, FileName, FileSize, User, Group, HardLinks};
|
||||||
use unix::get_current_user_id;
|
use unix::get_current_user_id;
|
||||||
use std::ascii::StrAsciiExt;
|
use std::ascii::StrAsciiExt;
|
||||||
|
|
||||||
@ -35,6 +35,7 @@ impl Options {
|
|||||||
getopts::optflag("a", "all", "show dot-files"),
|
getopts::optflag("a", "all", "show dot-files"),
|
||||||
getopts::optflag("b", "binary", "use binary prefixes in file sizes"),
|
getopts::optflag("b", "binary", "use binary prefixes in file sizes"),
|
||||||
getopts::optflag("g", "group", "show group as well as user"),
|
getopts::optflag("g", "group", "show group as well as user"),
|
||||||
|
getopts::optflag("l", "links", "show number of hard links"),
|
||||||
getopts::optflag("r", "reverse", "reverse order of files"),
|
getopts::optflag("r", "reverse", "reverse order of files"),
|
||||||
getopts::optopt("s", "sort", "field to sort by", "WORD"),
|
getopts::optopt("s", "sort", "field to sort by", "WORD"),
|
||||||
];
|
];
|
||||||
@ -52,11 +53,14 @@ impl Options {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn columns(matches: getopts::Matches) -> Vec<Column> {
|
fn columns(matches: getopts::Matches) -> Vec<Column> {
|
||||||
let mut columns = vec![
|
let mut columns = vec![Permissions];
|
||||||
Permissions,
|
|
||||||
FileSize(matches.opt_present("binary")),
|
if matches.opt_present("links") {
|
||||||
User(get_current_user_id()),
|
columns.push(HardLinks);
|
||||||
];
|
}
|
||||||
|
|
||||||
|
columns.push(FileSize(matches.opt_present("binary")));
|
||||||
|
columns.push(User(get_current_user_id()));
|
||||||
|
|
||||||
if matches.opt_present("group") {
|
if matches.opt_present("group") {
|
||||||
columns.push(Group);
|
columns.push(Group);
|
||||||
|
Loading…
Reference in New Issue
Block a user