Commit Graph

838 Commits

Author SHA1 Message Date
Benjamin Sago 99e52013b5 Version bump to 0.7.0 2017-07-07 11:47:47 +01:00
Benjamin Sago 690aa21ac8 Merge branch 'time-styles-properly'
This merges in the ability to use different time styles, such as full ISO-formatted timestamps instead of just using the default variable style.

Firstly, this moved the Environment from the Table to the Columns, so it 1) would only be instantiated when a table is actually used, and 2) can be affected by command-line options.

Next, it renames Columns to table::Options, in line with what the view optionses were renamed to.

Finally, it adds support for more time styles, deferring timestamp formatting to an enum.

Fixes #133.
2017-07-06 01:00:04 +01:00
Benjamin Sago 6afde85e18 Document --time-style, and completions 2017-07-06 00:52:27 +01:00
Benjamin Sago 3251378e91 Add iso time style 2017-07-06 00:39:54 +01:00
Benjamin Sago f0eed9fde4 Add full-iso time style 2017-07-06 00:21:38 +01:00
Benjamin Sago 786e8f4d7f Add long-iso style and --time-style option
This has to do its own number formatting because *somebody* didn’t add “print the current month number” functionality to rust-datetime!
2017-07-06 00:01:45 +01:00
Benjamin Sago 98b63705be Expect different time formats 2017-07-05 23:27:48 +01:00
Benjamin Sago aa5b1867dd Make nanoseconds available to times
The information was always in the Metadata struct; exa just never used it.
2017-07-05 23:08:56 +01:00
Benjamin Sago 5bdf6304bb Fix bug where accessed times were wrong!
It used the mtime, rather than the atime. Copy and paste error. Whoops!
2017-07-05 22:07:03 +01:00
Benjamin Sago ba335bb6e7 Separate TimeFormat from the Environment
By moving it outside of the Environment::load_all() constructor, it can be set to different values.
2017-07-05 21:54:43 +01:00
Benjamin Sago d93e168b4d Move Environment to a table’s Options
This commit moves the Environment field from the Table to its Options, and properly gets rid of the name ‘columns’ from the last commit.

Having it in the Options is important, because it means it can be generated from some command-line options. Also, it reduces the number of arguments that need to be passed to Table::new; there would have been 4 with the inclusion of the Environment, but by moving some of the code into the function, we can avoid this (and any further arguments).
2017-07-05 21:01:01 +01:00
Benjamin Sago 268b7d52dc Rename Columns to table::Options
The views have been renamed to be the Optionses of their module; now the options for the Table — Columns — has followed suit.

This works out, because the table module depended on everything in the columns module. It opens the door for other only-table-specific things to be included.

The casualty was that by making it non-Clone and non-PartialEq, a bunch of other #[derive]-d types had to have their derivions removed too.
2017-07-05 20:16:04 +01:00
Benjamin Sago d27812f819 Environment Default trait
The Environment struct only used the Default trait so it could have the same call for both Environment<UsersCache> and Environment<MockUsers>. There’s no reason to keep it around anymore.
2017-07-05 08:21:24 +01:00
Benjamin Sago 651d23fe8a Merge branch 'more-misc-refactorings'
This commit merges in a *lot* of refactoring work done to the tree, details, and grid-details views.

The main one is that the concept of a “table” has been completely separated from the details view. Previously, if you wanted to use the long view without drawing the table (such as with --tree), exa used a “table” with 0 columns in it behind the scenes. This is now reversed: the table is now the optional component in the details view, and a tree-only view is just a details view without a table!

Doing this has paved the way for all sorts of code cleanups: now, we only calculate values needed for the table if one’s going to be displayed. Some of these were rather expensive to compute (such as the user’s time zone, or locale)

This refactoring is not fully complete; there are still several things that can be done, including having the errors and xattrs in the tree view use the same TreeParams constructor as the others, and separating the column widths from the table so fewer mutable values need to be passed around.

Finally, this also merges in a lot of debuffering. There were at least two places in the code where values were collected into a vector before immediately being iterated over, instead of just using those values as they were generated! For example, when displaying the table, each row was rendered into a set of cells for displaying: but then it all went into a vector, and was only displayed at the very end, because that was what I needed for the grid-details view. Now, exa is smart enough to not do that.

Basically, even if exa doesn’t actually *get* that much faster, it should at least display its first line of output quicker.

Fixes #90, but also see #82.
2017-07-04 18:40:02 +01:00
Benjamin Sago f4ddbf3849 Fix tree permissions bug
There was a bug where if you tried to recurse into a directory you didn’t have permission to read the contents of, the error would be ignored.

It now displays the errors.
2017-07-04 17:48:30 +01:00
Benjamin Sago 882ac489ce Much more thorough xattr testing
It now tests a lot more combinations of xattrs on files, as well as xattrs and files and errors as the children of directories.

The recent code changes have touched the part where directories’ xattrs and children are displayed at the same tree level, and there weren’t enough tests for this.
2017-07-04 17:42:16 +01:00
Benjamin Sago 4c41141cb9 Give Tree its own iterator
The goal of this part of the refactoring, if you wondered, is to make it so only the tree module is aware that it needs ‘depth’ and ‘last’ values to draw the tree.

As far as the details module is concerned, it should just be doing something to produce TreeParams values which it later consumes; that’s it.

This change should make it easier to have tables that may or may not have a tree in them.
2017-07-04 08:29:36 +01:00
Benjamin Sago a32b0dfb47 Move this up 2017-07-04 08:10:37 +01:00
Benjamin Sago 80d5c2ad6d Rename some stuff 2017-07-03 23:25:56 +01:00
Benjamin Sago c0a2cf50af Encapsulate tree depth
It only really gets used for zeroes and having one added to it.
2017-07-03 23:15:50 +01:00
Benjamin Sago 8453f45f99 Make struct for all tree parameters
The fields for ‘depth’ and ‘last’ were being passed around separately, but were always used together.
2017-07-03 22:22:40 +01:00
Benjamin Sago 09b6ee7097 I give up 2017-07-03 20:53:37 +01:00
Benjamin Sago fec4c45301 Extract method for table widths total 2017-07-03 20:21:33 +01:00
Benjamin Sago 1b58f012e0 Split the details iterator in two
Instead of having one iterator that might or might not contain a table, have two, one per case.
2017-07-03 20:12:32 +01:00
Benjamin Sago 7b64176929 Encapsulate table widths
Adding a header row automatically added the widths to the table and returned the row, but adding a file’s row didn’t add the widths. Now they’re consistent.

By having the widths be in a separate type, we can separate the two out later, rather than having one refer to the other.
2017-07-03 17:40:05 +01:00
Benjamin Sago 97236128ea Only get an Env if one’s being used, also mutexes
This commit ties a table’s Environment to the fact that it contains columns.

Previously, the Details view would get its Environment, and then use those fields to actually display the details in the table: except for the case where we’re only displaying a tree, when it would just be ignored, instead.

This was caused by the “no columns” case using a Vec of no Columns behind the scenes, rather than disabling the table entirely; much like how a tap isn’t a zero-length swipe, the code should have been updated to reflect this. Now, the Environment is only created if it’s going to be used.

Also, fix a double-mutex-lock: the mutable Table had to be accessed under a lock, but the table contained a UsersCache, which *also* had to be accessed under a lock. This was changed so that the table is only updated *after* the threads have all been joined, so there’s no need for any lock at all. May fix #141, but not sure.
2017-07-03 17:04:37 +01:00
Benjamin Sago 5a2ffd3fbe Generate files with certain timestamps
This is going to be used to test time formatting.

Casualty here is that the “have you not ran the provisioning script in a year?” checker complained about there being files more than a year old, so that now has to ignore the times directory.
2017-07-03 08:46:38 +01:00
Benjamin Sago 652e27e6dd Extract time formatter
This commit collects all the time-related fields from the Environment and bundles them all together in their own encapsulated struct.
2017-07-03 08:45:14 +01:00
Benjamin Sago fc60838ff3 Extract table from details and grid_details
This commit extracts the common table element from the details and grid_details modules, and makes it its own reusable thing.

- A Table no longer holds the values it’s rendering; it just holds a continually-updated version of the maximum widths for each column. This means that all of the resulting values that turn into Rows — which here are either files, or file eggs — need to be stored *somewhere*, and that somewhere is a secondary vector that gets passed around and modified alongside the Table.
- Likewise, all the mutable methods that were on Table that added a Row now *return* the row that would have been added, hoping that the row does get stored somewhere. (It does, don’t worry.)
- Because rendering with mock users is tested in the user-field-rendering module, we don’t need to bother threading different types of U through the Environment, so now it’s just been specialised to UsersCache.
- Accidentally speed up printing a table by not buffering its entire output first when not necessary.
2017-07-02 01:02:17 +01:00
Benjamin Sago 22c6fb048f Merge branch 'sort-tests'
Adds some tests for sorting, and also adds --sort=type functionality.

Fixes #113.
2017-06-29 15:07:37 +01:00
Benjamin Sago f61e3853c1 Document sorting by type 2017-06-29 14:57:43 +01:00
Benjamin Sago f750536420 Add sorting by type
This isn’t perfect, as a file’s type isn’t cached, so it gets recomputed for every comparison in the sort! We can’t go off the file’s `st_mode` flag because it’s not guaranteed to be in any order between systems.
2017-06-29 14:52:02 +01:00
Benjamin Sago 7d1448da36 Add a test for inode sorting 2017-06-29 14:06:59 +01:00
Benjamin Sago 098788c98e Add sort tests for name and ext and lowercase 2017-06-29 14:03:17 +01:00
Benjamin Sago 9d74091195 Upcase some of the extension testcases
These are going to be used for sort testing. Unfortunately, three existing tests that were using the lowercase versions had to be changed.
2017-06-29 13:57:31 +01:00
Benjamin Sago 5cd7609034 Merge branch 'almost-all'
This merge adds support for `--all --all`, which displays the `.` and `..` directories like how ls does it.

Doing this was harder than it seemed — exa wasn’t filtering these directories out already, they just weren’t being included! So instead of just including them again, there had to be quite a lot of internal restructuring (yes, again) in order for there to be Files like `..` that don’t have the same name in the list as they do on the filesystem.

Fixes #155.
2017-06-29 13:34:45 +01:00
Benjamin Sago 7e302718fe Update the docs where it counts 2017-06-29 13:24:55 +01:00
Benjamin Sago 0aa33595d7 Use the optional argument trick 2017-06-29 13:17:26 +01:00
Benjamin Sago 31148eda7b Match up fields with parameter names
The arguments passed to File’s constructor were different from the field names used — these might as well both be the same.

Also, move ext and filename to be File methods to save an import, and add tests.

Also also, by passing a PathBuf in to the constructor directly, we can save one (possibly two) instance/s where we pass in a reference to something we were going to lose ownership of anyway, only to have it basically cloned.
2017-06-29 13:07:45 +01:00
Benjamin Sago 30f74b08b4 Always look up metadata
We can do this because the only File::new invocation that already has metadata is already in the file module, so it doesn’t need its own constructor.
2017-06-29 12:24:04 +01:00
Benjamin Sago 340bccbcfc Forbid --tree --all --all
There’s a problem with the tree view where it’ll still recurse through `.` and `..`. But if you were using tree view, would you even need to see them? They’d be in the tree already!
2017-06-29 12:07:46 +01:00
Benjamin Sago dd8bff083f Override the names of . and ..
There was a problem when displaying . and .. in directory listings: their names would normalise to actual names! So instead of literally seeing `.`, you’d see the current directory’s name, inserted in sort order into the list of results. Obviously this is not what we want.

In unrelated news, putting `.` and `..` into the list of paths read from a directory just takes up more heap space for something that’s basically constant.

We can solve both these problems at once by moving the DotFilter to the files iterator in Dir, rather than at the Dir’s creation. Having the iterator know whether it should display `.` and `..` means it can emit those files first, and because it knows what those files really represent, it can override their file names to actually be those sequences of dots.

This is not a perfect solution: the main casualty is that a File can now be constructed with a name, some metadata, both, or neither. This is currently handled with a bunch of Options, and returns IOResult even without doing any IO operations.

But at least all the tests pass!
2017-06-28 18:41:31 +01:00
Benjamin Sago 4295b243e5 Make Dir construction a bit cleaner 2017-06-27 18:13:18 +01:00
Benjamin Sago 20793ce7f4 Implement . and .. by inserting them maually
I originally thought that the entries . and .. were in *every* directory entry, and exa was already doing something to filter it out. And then... I could find no such code! Turns out, if we want those entries present, we have to insert them ourselves.

This was harder than expected. Because the file filter doesn’t have access to the parent directory path, it can’t “filter” the files vector by inserting the files at the beginning.

Instead, we do it at the iterator level. A directory can be scanned in three different ways depending on what sort of dotfiles, if any, are wanted. At this point, we already have access to the parent directory’s path, so we can just insert them manually. The enum got moved to the dir module because it’s used most there.
2017-06-27 01:13:50 +01:00
Benjamin Sago 39fd905999 Allow passing in the --all option more than once 2017-06-26 23:48:55 +01:00
Benjamin Sago 5ace1264f2 Move the show-invisibles flag into a struct 2017-06-26 23:28:10 +01:00
Benjamin Sago c7f18873fd Merge branch 'common-view-fields' 2017-06-26 23:03:29 +01:00
Benjamin Sago 4be0a36d4e Inline this thing
If a function returns one of several enum variants, but we’re only interested in one, then just return its contents and have it apply the Mode “wrapper” later.
2017-06-26 08:38:56 +01:00
Benjamin Sago 65d94636d7 Remove filter and dir_action from Details
These two fields were originally needed to determine how to recurse when using tree view.

However, as there was no distinction between the “options parsed from the command-line” Details and the “values needed to render a table” Details, these had to be threaded through the options parser as a special-case to end up in the right struct.

No more! Because there are separate structs for options and rendering, we can just add them in later.
2017-06-26 08:28:32 +01:00
Benjamin Sago 14144e2ad3 Create Render structs from views
Instead of having render methods on the types that are now called Options, create new Render structs (one per view) and execute them. This means that it’s easier to extract methods from them — some of them are pretty long.

Also, remove the GridDetails struct, which got consumed by Mode (mostly)

By introducing another indirection between the structs that command-line options get parsed into and the structs that get rendered, it should be easier to refactor that horrible function in view.rs.
2017-06-26 00:53:48 +01:00