Add --bytes to not use prefixes at all

This commit is contained in:
Ben S 2014-12-18 07:04:31 +00:00
parent f03a496424
commit a871a448be
4 changed files with 8 additions and 1 deletions

View File

@ -13,6 +13,7 @@ exa is a replacement for `ls` written in Rust.
- **-1**, **--oneline**: display one entry per line
- **-a**, **--all**: show dot files
- **-b**, **--binary**: use binary (power of two) file sizes
- **-B**, **--bytes**: list file sizes in bytes, without prefixes
- **-d**, **--list-dirs**: list directories as regular files
- **-g**, **--group**: show group as well as user
- **-h**, **--header**: show a header row

View File

@ -14,6 +14,7 @@ impl Copy for Column { }
pub enum SizeFormat {
DecimalBytes,
BinaryBytes,
JustBytes,
}
impl Copy for SizeFormat { }

View File

@ -235,6 +235,7 @@ impl<'a> File<'a> {
let result = match size_format {
SizeFormat::DecimalBytes => decimal_prefix(self.stat.size as f64),
SizeFormat::BinaryBytes => binary_prefix(self.stat.size as f64),
SizeFormat::JustBytes => return Green.bold().paint(self.stat.size.to_string().as_slice()).to_string(),
};
match result {

View File

@ -49,6 +49,7 @@ impl Options {
getopts::optflag("1", "oneline", "display one entry per line"),
getopts::optflag("a", "all", "show dot-files"),
getopts::optflag("b", "binary", "use binary prefixes in file sizes"),
getopts::optflag("B", "bytes", "list file sizes in bytes, without prefixes"),
getopts::optflag("d", "list-dirs", "list directories as regular files"),
getopts::optflag("g", "group", "show group as well as user"),
getopts::optflag("h", "header", "show a header row at the top"),
@ -117,6 +118,9 @@ impl Options {
if matches.opt_present("binary") {
columns.push(FileSize(SizeFormat::BinaryBytes))
}
else if matches.opt_present("bytes") {
columns.push(FileSize(SizeFormat::JustBytes))
}
else {
columns.push(FileSize(SizeFormat::DecimalBytes))
}