Commit Graph

34 Commits

Author SHA1 Message Date
Ben S
038143682c Add header row with -h option 2014-06-23 18:26:35 +01:00
Ben S
49d3caf0e9 Print directory names when given more than one 2014-06-21 18:12:29 +01:00
Ben S
b5a1b24bda Cache user and group names
I checked strace and it was reading /etc/passwd every time it needed to
look up a user or group. Now it only does it once per.
2014-06-21 17:50:37 +01:00
Ben S
92b45e6908 Handle errors instead of fail!()ing
Dir::readdir and File::from path now both return IoResults, rather than just calling fail! and exiting. This allows the program to continue after an error.
2014-06-20 21:07:53 +01:00
Ben S
355ca51617 Stop adding spaces to the end of each line
This left-aligns the final column, but the final column is the file name, so that's okay.
2014-06-20 19:43:15 +01:00
Ben S
2bb563d448 Upgrade to latest Rust nightly
- s/syntax/phase
- no more boxed array syntax
- getopts fail implements Show
- option#expect now requires &str
2014-06-18 13:39:55 +01:00
Ben S
03ec414dfb Move file-type detection to its own module
I'd much rather have this separate, as it has the definite potential to
balloon up to a huge size and end up making the other parts of the file
module hard to read. But on the other hand, it meant making a few more
methods public on file... readability over cleanliness, I guess.
2014-06-17 09:35:40 +01:00
Ben S
a5e404da55 Cache readdir results in a Dir object
This new object is then passed down to the File, so it can see what files are around it. This means it doesn't need to re-query the filesystem several times per file, instead using the in-memory copy.

Also, switch to using the built-in Path#with_extension method.
2014-06-17 00:27:05 +01:00
Ben S
e5e426fc60 Right-align file sizes
Currently there's only one numeric column, and that's the file size, so it gets
special treatment.

I was originally going to have a folder file size field be filled up with '-'s
as far as it could go, leaving it entirely up to the column how its field gets
formatted. But then I saw just one '-' working just fine, so I left it like
that. In the first try, columns could do anything they want when padding a
string (including changing the padding character or just changing it entirely),
but now there's no point.
2014-06-04 13:45:14 +01:00
Ben S
2d41333117 Upgrade to latest Rust nightly
- s/to_owned/to_string/g
- TotalEq/TotalOrd changes
- snake_case of identifiers
2014-06-02 21:02:06 +01:00
Ben S
4722c8991b Implement natural sorting on filenames 2014-06-01 11:54:31 +01:00
Ben S
48d8a46df8 Code cleanup (commenting the why) 2014-05-27 12:37:51 +01:00
Ben S
0dd74a022f Add --binary flag
This finally means that the list of columns is no longer fixed, which means it has to be generated somewhere. And guess where it got moved to? That's right, the options object! (see previous commits)
2014-05-26 15:44:16 +01:00
Ben S
573765b62b Move filtering to options object, too
I'd like to have as few public methods on it as possible.
2014-05-26 12:46:51 +01:00
Ben S
1dbe20c8c5 Move sorting and reversing into options object 2014-05-26 11:50:46 +01:00
Ben S
05b2d541ac s/StrBuf/String/g 2014-05-26 11:08:33 +01:00
Ben S
566ed0bba8 Move columns to options object 2014-05-25 19:42:31 +01:00
Ben S
cb6dd57ca0 Move getopts code into options module 2014-05-25 18:14:00 +01:00
Ben S
ff0bef66e5 Cache the lengths of formatting-striped fields
The code could do with some comments, but it works.
2014-05-25 17:14:50 +01:00
Ben S
b116889abc Change format of file sizes to be shorter
I'm copying ls here because we don't really need the 'B' for bytes to be
listed every time. I think it looks better the new way. Unlike ls, don't
list directory sizes, because I've never found the pseudo-sizes they get
given at all useful.

Also, fix a bug where aligning columns didn't work when the number of
format characters (like '\x1B' and '[') were different between each
line.
2014-05-25 15:52:36 +01:00
Ben S
d60c2ce839 Add reverse parameter 2014-05-24 21:45:24 +01:00
Ben S
cb1b8bc2d7 Add sort option
And move options struct into its own module
2014-05-24 02:17:43 +01:00
Ben S
fdf58e887b Upgrade to latest Rust (s/~str/StrBuf/)
See https://github.com/mozilla/rust/pull/14310
2014-05-24 01:14:40 +01:00
Ben S
a0582132e5 Have each row use the same column widths
This involves putting the entire output into a table before anything
is actually printed, in order to determine what the width of each
column should be. This should make it appear to output slower, as the
first line can only be printed after every file has been examined, but
it's still fast to me.
2014-05-22 13:22:41 +01:00
Ben S
818fc615a8 Upgrade to latest Rust nightly 2014-05-22 13:17:33 +01:00
Ben S
d76fee7328 Add user and group columns
This meant writing some libc interaction, which wasn't actually too bad.
2014-05-05 11:29:50 +01:00
Ben S
d6e34723b9 Upgrade to latest Rust nightly
Replace ~strs with either &'static strs or .to_owned() strs where appropriate
Fields now seem to be private by default - good!
2014-05-05 10:51:24 +01:00
Ben S
e4cee37805 Fix various warnings 2014-05-04 21:35:10 +01:00
Ben S
10b8f6f414 Split source out into multiple files
Also, reverse the way columns are rendered: before, a column took a stat and a name to render; now, a file takes a column type to render. This means that most of the File data/methods can be private.
2014-05-04 21:33:14 +01:00
Ben S
e0fc84e869 Add --all command-line option
Also add command-line-option-handling code.
2014-05-04 17:01:54 +01:00
Ben S
af7689eb0b Keep files and their stat results together
Thanks to #rust for helping me diagnose lifetime problems!
2014-05-04 16:28:42 +01:00
Ben S
688e41e401 Add file size column 2014-05-03 14:26:49 +01:00
Ben S
aef325bde9 Make columns more generic 2014-05-03 14:00:50 +01:00
Ben S
dc9668c8d6 Initial commit 2014-05-03 11:30:37 +01:00