Commit Graph

805 Commits

Author SHA1 Message Date
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
Benjamin Sago
66491cbae3 Separate colours from mode deduction
Now that colours don’t depend on a previously-calculated “should we be using colours” boolean anymore, their entire deduce function can be done separately to the mode’s one.
2017-06-25 14:59:38 +01:00
Benjamin Sago
84b01f2064 Fix bug where colours were incorrectly applied
exa assumed that the COLUMNS environment variable being present always meant that the output was to a terminal, so it should use colours. But because this variable can be overridden, colours were being incorrectly set!

The ‘fix’ is to stop trying to be clever while only calculating the terminal width once, and instead just stick it in a lazy_static so it’s usable everywhere.
2017-06-25 14:51:44 +01:00
Benjamin Sago
b8bb148fbb usize is Copy 2017-06-25 12:49:22 +01:00
Benjamin Sago
183ed9c135 Separate classify from the other two fields
This makes the code messier, but it’s just a stepping-stone until colours gets separated too.
2017-06-25 12:32:08 +01:00
Benjamin Sago
4e90b4d7e3 Tests for disabling colours 2017-06-25 11:53:59 +01:00
Benjamin Sago
ed3d28f2cd Extract common classify 2017-06-24 22:53:34 +01:00
Benjamin Sago
aea0035f94 Move Colour and Classify to the View
All four view types — lines, grid, details, and grid-details — held their own colours and classify flags.

This didn’t make any sense for the grid-details view, which had to pick which one to use: the values were in there twice.

It also gave the Table in the details view access to more information than it really should have had.

Now, those two flags are returned separately from the view “mode”, which is the new term for one of those four things.
2017-06-24 22:39:15 +01:00
Benjamin Sago
763e833b6f Merge branch 'help!' 2017-06-23 23:00:02 +01:00
Benjamin Sago
81c5d8b7c6 Avoid allocating vectors for the help text 2017-06-23 22:58:07 +01:00
Benjamin Sago
4018165e26 Avoid an allocation when printing help text 2017-06-23 22:50:29 +01:00
Benjamin Sago
4e32b7fca9 Remove one last newline from help output 2017-06-23 22:30:48 +01:00
Benjamin Sago
aa17e4d3df Make a common module of exit statuses 2017-06-23 22:27:33 +01:00
Benjamin Sago
e4e603b4ee There’s more to erroneousness than an exit code 2017-06-23 22:12:21 +01:00
Benjamin Sago
a060782312 Require version and help text to be on stdout 2017-06-23 22:03:58 +01:00
Benjamin Sago
90e0c5b60e Add tests for --help --long 2017-06-23 21:31:13 +01:00
Benjamin Sago
c5b18d0f6b Remove extra newline from help text 2017-06-23 21:25:55 +01:00
Benjamin Sago
8308638dd9 Add a test for --help 2017-06-23 21:22:48 +01:00
Benjamin Sago
ded829f073 Move help generation to its own function 2017-06-23 21:22:39 +01:00
Benjamin Sago
aaa8876f49 Merge pull request #186 from gyscos/master
Update dependencies
2017-06-16 00:21:02 +01:00
Alexandre Bury
f79acc76c4 Update dependencies 2017-06-11 01:34:02 -07:00
Benjamin Sago
110613bf95 Merge branch 'sticky-bits'
This adds support for the setuid, setgid, and sticky bits like how ls does it: by replacing the user/group/execute bits with different flags depending on their presence. At least we do it with flair, and by flair, I mean purple.

Fixes #142
2017-05-30 15:33:45 +01:00
Benjamin Sago
c4447e35b6 xtests for higher order bits
Finally, re-do the permissions extended tests to include the setuid, setgid, and sticky bits, and rename the last two existing ones to match the others (files with the same names as their permissions).
2017-05-30 15:32:11 +01:00
Benjamin Sago
a2901c63cf Render higher permission bits
Unlike the others, setuid/setgid/sticky get merged with user/group/other execute in the rendered Permissions cell. So there had to be a bit of code change done to make sure that none of the bits clashed.
2017-05-30 15:31:24 +01:00
Benjamin Sago
f9f7ad2230 Read setuid/setgid/sticky bits
The problem here was that we were using `metadata.permissions().mode()`, which is capped at 0o777, rather than `metadata.mode()`, which exposes every bit. With this change, we can access the higher-order permission bits, and put them in the Permissions struct.
2017-05-30 15:29:29 +01:00
Benjamin Sago
bd860b8fab Merge branch 'split-details' 2017-05-30 14:58:14 +01:00
Benjamin Sago
b5d5509657 Timestamps will need more work 2017-05-22 08:52:45 +01:00
Benjamin Sago
4a5cb5361d Inode is probably the easiest one 2017-05-22 08:51:34 +01:00
Benjamin Sago
094e660003 Monday morning Blocks extraction 2017-05-22 08:48:32 +01:00
Benjamin Sago
eec81c4f48 Monday morning Links extraction 2017-05-22 08:43:09 +01:00
Benjamin Sago
f0cf5b4538 A Git status character should render itself, too 2017-05-21 17:01:22 +01:00
Benjamin Sago
5f497da85d This actually makes the Git part big enough
…for its own module.
2017-05-21 16:59:02 +01:00
Benjamin Sago
9642f69ce7 Tests for Git rendering 2017-05-21 16:54:40 +01:00
Benjamin Sago
b6c425c415 Did I forget to finish writing this comment? 2017-05-21 15:33:15 +01:00