Переглянути джерело

Add --bytes to not use prefixes at all

Ben S 11 роки тому
батько
коміт
a871a448be
4 змінених файлів з 8 додано та 1 видалено
  1. 1 0
      README.md
  2. 1 0
      src/column.rs
  3. 2 1
      src/file.rs
  4. 4 0
      src/options.rs

+ 1 - 0
README.md

@@ -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

+ 1 - 0
src/column.rs

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

+ 2 - 1
src/file.rs

@@ -234,7 +234,8 @@ impl<'a> File<'a> {
         else {
         	let result = match size_format {
         		SizeFormat::DecimalBytes => decimal_prefix(self.stat.size as f64),
-        		SizeFormat::BinaryBytes => binary_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 {

+ 4 - 0
src/options.rs

@@ -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))
 		}