Commit Graph

73 Commits

Author SHA1 Message Date
Ben S
38a785426b Fix overflowing UIDs and GIDs
Fixes #26.
2015-02-23 13:37:59 +00:00
Ben S
1da1142a7e Fix panic when previewing symlink to ., .., or /
The old implementation blindly assumed that a symlink target would have a directory compoment, which the current directory, parent directory, and root directory technically don't have.

Fixes #20.
2015-02-23 11:32:35 +00:00
Ben S
e21dc9af2a Merge pull request #21 from coyotebush/git-paths
Improve matching of Git status entries to files
2015-02-23 00:46:36 +00:00
Ben S
ae39d0f8a7 Merge pull request #19 from Stebalien/replace-as_slice
Get rid of explicit `as_slice()` calls
2015-02-22 23:50:38 +00:00
nwin
beaf8789ce true -> false 2015-02-23 00:08:44 +01:00
Corey Ford
6e19563879 Improve matching of Git status entries to files
The challenge is that the paths returned from libgit2's status listing
are from the perspective of the Git repository and thus effectively
relative to the working tree root, while the other paths we're
manipulating are (potentially) relative to our current working
directory. So, if those two aren't identical (if running from outside
the working tree, or from a subdirectory), the paths won't match up.

A reasonably reliable way around this is to resolve both types of paths
to absolute paths before comparing them. This fixes #15 at a basic
level, anyway.

What still doesn't work: referring to the working tree or one of its
descendants via a symlink. For that, we'd probably need to fully resolve
symlinks in the file path.

(The unwrap_or()'s are messy and will probably just result in missing
status information, but then, what information could you hope to get
without having both a current working directory and a Git working tree?)
2015-02-22 14:44:54 -08:00
nwin
0082563e47 Using the same alignment as ls. 2015-02-22 18:50:52 +01:00
nwin
8ac16fad8a Using convenience method and using extended clusters as recommended. 2015-02-22 18:36:11 +01:00
Steven Allen
2b5406842f Get rid of explicit as_slice() calls. 2015-02-22 12:11:33 -05:00
Ben S
b2ed264ba4 Upgrade to latest Rust
- Feature flags changes (old_io, old_path)
- Slice syntax changes ([] -> [..])
2015-02-21 13:54:35 +00:00
Ben S
03a05b7020 Detab 2015-02-13 21:24:29 +00:00
Ben S
d180a5f5e4 Use ansi_term's awesome new continuation colours 2015-02-13 21:24:10 +00:00
Ben S
ec51867a53 Upgrade to latest Rust
- Update package versions
- locale::default -> locale::english
- Argument handling changes
2015-02-12 22:33:01 +00:00
Ben S
2906b8676a Translate month names into the user's locale
This has been mostly done with changes in the datetime crate's suddenly
supporting locales.

It's still important that the user's locale is touched only once and
cached from that point on, so a struct in output::details has been made
public, along with that module. This will change later as that object
gains more and more uses thoughout the codes.
2015-02-10 18:14:56 +00:00
Ben S
e39a20a5d4 Use locale-defined decimal separator
Also, fix the broken tests by just using the default locale at test
time.
2015-02-10 16:42:25 +00:00
Ben S
84b18e5521 Add thousands seps to links and blocks columns 2015-02-10 16:21:19 +00:00
Ben S
21ac16f808 Format file size in bytes with the user's locale
Use the `locale` crate as a dependency to read in the set
thousands-separator character, and pass this to the file size column,
which uses it to add the separators in.

en_GB uses ","
fr_FR uses "" and just displays the numbers in one go.
2015-02-10 16:08:10 +00:00
Ben S
8b520edf3d Only display the year if it's last year
Otherwise, just display the hour and minute.
2015-02-09 18:14:05 +00:00
Ben S
bc7492e7e6 Add hour and minute to timestamps 2015-02-09 17:55:55 +00:00
Ben S
bf815afa8e Use short month names to make them line up 2015-02-09 17:37:02 +00:00
Ben S
0d25a90ef1 Initial work on date/time columns for files
Using the datetime crate, add an extra column to the --long view that
prints out the modified, accessed, or created timestamp for each file.
Also, let the user pick which one they want to see based on the --time
command-line option.
2015-02-09 16:33:27 +00:00
Ben S
42ae7b3d33 Refactor the code after tree view changes
- Turn the views and main program loop into structs, rather than just as one gigantic function
- Separate views into their own files

The addition of the git column and the tree view meant that a lot of functions now just took extra arguments that didn't seem to fit. For example, it didn't really work to have only one 'view' method that printed out everything, as the different view options now all take different parameters.
2015-02-05 14:39:56 +00:00
Ben S
1bced1423b Fix tests from tree view fallout 2015-02-04 01:12:08 +00:00
Ben S
827a1e11fd Make filename not a column
FileName was always a special-cased column, as it was assumed to be the last column in the output. Now, it's explicitly marked as such. This allows the hash marks to be placed before the filename, rather than at the start of the line.
2015-02-03 13:48:39 +00:00
Ben S
5099b3f119 Initial tree implementation
There's still a lot to do, but this is actually *something*. The tree hierarchy is displayed using hashes at the start of a line. I want to have it just before the filename, but this will need some changes to the way that columns are handled.
2015-02-03 13:27:23 +00:00
Ben S
10096d1043 Prevent crash for filenames with no components
Now there are no more unwrap()s!
2015-01-31 17:18:53 +00:00
Ben S
6d4b30d531 Code changes in preparation for recursion 2015-01-31 16:10:40 +00:00
Ben S
947087567c Upgrade to latest Rust
- Rename std::io to std::old_io
2015-01-28 16:55:34 +00:00
Ben S
f794f5eda6 Implement Git status for directories 2015-01-28 10:43:19 +00:00
Ben S
90d4684de4 Preliminary Git support!
This is something that I've long wanted to add. It uses libgit2 as an optional dependency.
2015-01-27 15:01:17 +00:00
Ben S
e835fe8fe3 Make all fields of Dir private 2015-01-26 17:26:11 +00:00
Ben S
da9d1f77d9 Cache the lowercased extension
Extensions aren't ever displayed in lowercase, just compared case-insensitively, so this makes sense.
2015-01-26 01:16:19 +00:00
Benjamin Sago
628d90fe44 Test extension extraction 2015-01-25 13:47:07 +00:00
Benjamin Sago
ef4428fab1 Test highlighting of groups and group names 2015-01-25 13:43:44 +00:00
Benjamin Sago
191c0e5b90 Test highlighting of usernames 2015-01-25 13:04:15 +00:00
Benjamin Sago
c53a0156e6 Extract symlink stuff into its own method 2015-01-24 17:34:33 +00:00
Benjamin Sago
449592c150 Do column width calculations ourselves (speedup)
Instead of stripping the ANSI formatting characters from our strings, work out the length without them and use that. This is per-column, but most of them are simple (just the same number of characters in the non-coloured string).

Sometimes, this is really simple: for example, trwxrwxrwx permissions strings are always going to be ten characters long, and the strings that get returned are chock full of ANSI escape codes.

This should have a small benefit on performance.
2015-01-24 17:26:26 +00:00
Ben S
2ba0b3bd5f Convert docs to standard format 2015-01-24 12:38:05 +00:00
Ben S
0e473bf37b Upgrade to latest Rust, and move options code 2015-01-23 19:27:06 +00:00
Benjamin Sago
1c5409e253 Upgrade to Rust alpha
- uint -> usize
- getopts Cargo library
- replace feature gates with unstable APIs
2015-01-12 01:31:24 +01:00
Ben S
d400231de5 Upgrade to latest Rust
Also, remove dependency on the Regex library by replacing the one place it was used with standard code that should hopefully be faster anyway.
2015-01-05 14:41:43 +00:00
Ben S
a871a448be Add --bytes to not use prefixes at all 2014-12-18 07:04:31 +00:00
Ben S
f03a496424 Only underline executable *files* in perms view 2014-12-18 07:00:51 +00:00
Ben S
24628f97be Use number_prefix crate for number prefixes 2014-12-18 07:00:31 +00:00
Ben S
bcaed1ff35 Remove redundant slicing 2014-12-12 14:17:57 +00:00
Ben S
57430dbbe5 Why be so specific?
Different types of user caches could come in the future...
2014-12-12 14:13:08 +00:00
Ben S
66339e7a15 Miscellaneous little optimisations
- Prefer iter over into_iter where appropriate
- Cut down on cloning
2014-12-12 14:06:48 +00:00
Ben S
65f124fe39 Use the natord library instead of our own sorter
I'm serious, the more functionality I can use external crates for, the better.
2014-12-12 11:26:18 +00:00
Ben S
6770ac5475 Replare Unix module with users crate
Feels good turning all that code into a dependency!
2014-12-12 11:17:55 +00:00
Ben S
6134096586 Upgrade to latest Rust
I can't complain, because the breaking changes were caused by my pull request...
2014-12-02 14:20:28 +00:00