Commit Graph

250 Commits

Author SHA1 Message Date
Alex Soderman
217d1eefa9 moved icons functionality to grid mode 2018-03-26 17:02:05 -04:00
Alex Soderman
57e8802977 Added icons mode w/ prepending (icons themselves do not appear yet) 2018-03-22 19:13:02 -04:00
Alex Soderman
67f2fcc748 Added --icons flag 2018-03-20 22:30:41 -04:00
BenWhitehead
a156d96768 Add new sort option .name and .Name
Add two new sort options `.name` and `.Name` which with ignore a leading
`.` if present on the file name before sorting according to `name` and
`Name`.

This new sort is convenient if you want to list hidden and unhidden
files sorted together.
2018-01-30 15:01:56 -08:00
Martin Lindhe
7b1ee01eb5 adjust some spelling 2017-10-31 06:24:31 +01:00
Benjamin Sago
c7497f3778 Display more information for non-release releases 2017-10-08 20:09:46 +01:00
Benjamin Sago
e154b58268 Move EXA_DEBUG variable to vars file 2017-10-08 17:24:50 +01:00
Benjamin Sago
59d9e90f20 Replace “mi” colour with “bO” overlay
Fixes #288, but more-or-less as a side-effect.

The “mi” key in LS_COLORS was meant to be used for a missing link path, but it wasn’t really used like that. There was also a bug where control characters in a broken symlink’s path were assumed to be underlined, because that’s what happened in the default colour scheme, but this assumption doesn’t hold when colours were disabled.

The solution to these was not to introduce another configurable colour code, but to start using _overlays_ to alter a bunch of colours at once. The “mi” code will have to be added back later.
2017-10-08 17:08:07 +01:00
Benjamin Sago
b95446d834 Thread an ignore cache through the program
!
2017-09-30 09:17:29 +02:00
Benjamin Sago
07443e87ba Add a --git-ignore option that doesn’t do anything
!!
2017-09-30 09:17:28 +02:00
Mahmoud Al-Qudsi
ad02241ac2 Merge branch 'master' into optional_args 2017-09-16 14:28:24 -05:00
Benjamin Sago
c475cccce4 Flip the new/old order, and add suggestion for -lt
I changed my mind about which way round sorting by “newest” or by “oldest” should actually go. If you’re listing a large directory, you see the last lines of the output first, so these files should be the ones with the largest whatever the sort field is. It’s about sorting *last*, not sorting *first*. Sorting by size wouldn’t say “sorts smallest files first”, it would say “sorts largest files last”. Right?

Also, add a new suggestion that warns against “ls -lt”.
2017-09-14 09:18:17 +01:00
Benjamin Sago
a8bf990674 Tie value suggestions to their arguments
This commit changes the definition of Arg so that it knows about which values it can accept, and can display them in the help text. They were already being shown in the help text, but they were passed in separately, so one argument could show two different sets of options if it wanted. Now, the argument itself knows whether there are suggestions, so it doesn’t have to be passed in separately.

This means we can use it for other things, including listing choices when an option is missed out, without having to repeat the list.

With Misfire::BadArgument now only having two fields, it’s not worth using a constructor function anymore.
2017-09-14 01:22:37 +01:00
Mahmoud Al-Qudsi
36cf5df044 Add support for optional argument/flag with optional value
TakesValue::Optional introduced which allows for an optional flag with
an optional value (equivalent to getopts' optflagopt mode).

Can be used where a default value for a modifier could exist, but the
user might prefer to override.

Will be used to implement #284, permitting --time to default to "sort by
modification date" for compatibility with GNU/posix ls but keeping
support for exa's previous behavior.
2017-09-13 18:48:59 -05:00
Benjamin Sago
1824313cda Put misfire.rs in a nicer order
The main type is now at the top.
2017-09-13 23:49:30 +01:00
Benjamin Sago
43bbf00478 Show a warning when running ‘exa -ltr’
Raised in #243 and #284. exa isn’t able to override the -t option like this, so the least it can do is detect that case (which is going to be an error case anyway) and show a suggestion.
2017-09-13 23:47:19 +01:00
Benjamin Sago
0fefc78cbb Add more modified date aliases
I don’t really see the modified date as the *modified* date, rather just the *date* field, because it’s the date field I refer to like 99.9% of the time. So now it has aliases to match.

Also are included are aliases for the reverse order, because I’d rather write “new” than “the reverse of old”.
2017-09-13 23:26:06 +01:00
Benjamin Sago
19b7780755 Fix typo in error message
It said “(Choices: (choices: this, that, other))” instead of “(choices: this, that, other)”. Also improve the same error elsewhere: options more have ‘settings’ than ‘values’.
2017-09-13 22:37:51 +01:00
Benjamin Sago
dc45332d7b Implement file name colouring in {exa,ls}_colors
This commit adds to the parsing of the LS_COLORS and EXA_COLORS variables so that non-two-letter codes (keys other than things like ‘di’ or ‘ln’ or ‘ex’) will be treated as file name globs, and get used to colour files accordingly.

Fixes #116 for good.
2017-09-13 08:51:57 +01:00
Benjamin Sago
b86074d63b Rename Style to Styles to avoid a name clash 2017-09-13 08:44:59 +01:00
Benjamin Sago
28b4b672d4 Move FileStyle to the same options file as Colours
They are going to be deduced together (from the same environment variable) so it makes sense to put them in the same file first.
2017-09-03 19:50:40 +01:00
Benjamin Sago
45a807a14f Redo Git implementation to allow --git --recurse
This is all a big commit because it took a lot more work than I thought it would! The commit basically moves Git repositories from being per-directory to living for the whole life of the program. This allows for several directories in the same repository to be listed in the same invocation; before, it would try to rediscover the repository each time! This is why two of the tests “broke”: it suddenly started working with --recurse.

The Dir type does now not use Git at all; because a Dir doesn’t have a Git, then a File doesn’t have one either, so the Git cache gets passed to the render functions which will put them in the Table to render them.
2017-09-01 19:13:47 +01:00
Benjamin Sago
d86fc4286b \t and \s+$ 2017-08-26 23:54:12 +01:00
Benjamin Sago
f6b7b7f298 Add exa_colors to make exa themable
This adds support for the EXA_COLORS environment variable, and defines a bunch of exa-specific two-letter codes that I pretty much made up arbitrarily that control parts of the interface.

Fixes #160, which I didn’t expect to actually fix this release cycle, but it unexpectedly became easy to do!
2017-08-26 23:17:07 +01:00
Benjamin Sago
504a0dd6b7 Stop collecting ls_colors into a hashmap
LSColors used to be built up from an iterator, and then queried later. But because the resulting HashMap gets queried in serial anyway, we might as well pass in a callback instead, saving the allocation.

This is also technically a little faster because styles that don’t map to anything (like `zz`) are no longer parsed.
2017-08-26 22:33:16 +01:00
Benjamin Sago
dd838c2dc1 Move Colours and LSColors to their own module
The ‘options’ module is allowed to depend on ‘style’, but ‘options::render’ is not.
2017-08-26 21:40:37 +01:00
Benjamin Sago
945fa1e83d Isolate and document the environment variables 2017-08-26 21:36:27 +01:00
Benjamin Sago
bf8ff3675b Move Vars into its own module 2017-08-26 20:48:51 +01:00
Benjamin Sago
bfb8a5a573 Extract trait above file name colours
This commit meddles about with both the Colours and the FileExtensions.

Even though all the renderable fields were turned into traits, the FileName struct kept on accessing fields directly on the Colours value instead of calling methods on it. It also did the usual amount of colour misappropriation (such as ‘punctuation’ instead of specifying ‘normal_arrow’)

In preparation for when custom file colours are configurable (any day now), the colourise-file-by-kind functionality (links, sockets, or directories) was separated from the colourise-file-by-name functionality (images, videos, archives). The FileStyle struct already allowed for both to be separate; it was only changed so that a type other than FileExtensions could be used instead, as long as it implements the FileColours trait. (I feel like I should re-visit the naming of all these at some point in the future)

The decision to separate the two means that FileExtensions is the one assigning the colours, rather than going through the fields on a Colours value, which have all been removed. This is why a bunch of arbitrary Styles now exist in filetype.rs.

Because the decision on which colourise-file-by-name code to use (currently just the standard extensions, or nothing if we aren’t colourising) is now determined by the Colours type (instead of being derived), it’s possible to get it wrong. And wrong it was! There was a bug where file names were colourised even though the rest of the --long output wasn’t, and this wasn’t caught by the xtests. It is now.
2017-08-26 20:43:47 +01:00
Benjamin Sago
276d18cf7c Give block and character devices different colours
There are now two device colours instead of one. Even though they’re both set to the same style for the default colour set, LS_COLORS allows the two to look different, so exa has to support it too.

It’s probably a good idea to support it anyway.
2017-08-26 14:30:33 +01:00
Benjamin Sago
bd8e9d819c Add more ls_colors colours 2017-08-26 14:04:49 +01:00
Benjamin Sago
d517e9e12b Split FileTypes into types and kinds
This separates the colours to give to files with different filesystem types (directories, links, sockets) from files with different names or extensions (images, videos, archives).

I’m not 100% sure I’ve got the terms “kind” and “type” the right way round, but whatever.

This was done because colouring files based on their name is going to be handled differently and extensibly from colouring files based on what the filesystem thinks.
2017-08-25 17:50:22 +01:00
Benjamin Sago
fb3395883e Start actually parsing ls_colors
So far it only changes the colour of a directory, but it’s a start.
2017-08-25 17:43:36 +01:00
Benjamin Sago
59edc3b6ea These tests don’t need a type
Because the macros are now specialised to the type that’s being deduce-d, we don’t need to specify what the type is every time.
2017-08-25 09:07:28 +01:00
Benjamin Sago
974ddc0e63 Tests for turning colours on/off 2017-08-25 09:03:47 +01:00
Benjamin Sago
a581c871ed Split the colours tests in two
The TerminalColours tests used half the macros, and the Colours tests used the other half. Now only the macros used are actually in scope.
2017-08-25 08:53:35 +01:00
Benjamin Sago
4907565baf Move colour options to their own file 2017-08-24 23:38:26 +01:00
Benjamin Sago
30f3c6eb00 Strict mode and tests for colour scale 2017-08-23 11:45:29 +01:00
Benjamin Sago
57c647fee5 Default to sorting case-insensitively
This was touched on in #209 where I got the docs wrong compared to the actual implementation, but after thinking about it, I’d like to switch it round. (The --sort=Name and --sort=name difference has also been switched.) See the big ol’ comment for my reasons.

Because this changes core functionality, it broke many, many tests. You can see that this doesn’t change the -star- tests because the shell, rather than exa, orders the globbed files.

I kept on forgetting which way round Sensitive and Insensitive went, so I named them after the effect they have.
2017-08-20 17:33:39 +01:00
Benjamin Sago
4c16f50565 Fix an error being displayed weirdly
The Debug impl was being used instead of the Display one. Also, remove the full stops from the ends of all the error messages because I’ve decided it looks weird.
2017-08-19 22:17:53 +01:00
Benjamin Sago
bcf5213cc8 Tie the row threshold to EXA_GRID_ROWS
This makes it its own type, rather than just another environment variable that’s easily missed.
2017-08-13 11:15:40 +01:00
Benjamin Sago
6740faa781 env vars should be referenced, not copied
Just because the type that gets used right now is Copy and Clone doesn’t mean that when we pass mock ones in for tests they’ll be those two as well. So we have to go through and add &s everywhere.
2017-08-13 11:14:58 +01:00
Benjamin Sago
33e83accd0 match-to-if-let 2017-08-12 22:51:45 +01:00
Benjamin Sago
da00e2fda2 Thread the row threshold through grid_details
No new features here, just some restructuring. Mode::GridDetails was nice and elegant with those two fields, but now there’s a grid-details-only option the elegance has gone out the window.
2017-08-12 22:49:16 +01:00
Benjamin Sago
e45e515805 Remove stray colon from help text
Fixes #266
2017-08-12 11:39:12 +01:00
Benjamin Sago
9e15c616cc dir_action comments and docs 2017-08-12 11:29:40 +01:00
Benjamin Sago
673e894d25 Give the filter modules some love 2017-08-12 10:09:33 +01:00
Benjamin Sago
a7d8e1c84b Make the dir action a bit more lenient
More strict mode checks I forgot to take out
2017-08-11 22:56:52 +01:00
Benjamin Sago
eec1a4f78a Stop --git from complaining too
Re-fixes #152
2017-08-11 21:43:56 +01:00
Benjamin Sago
b286676667 Add actual error messages for the error messages
The annoying part is trying to format!() an OsStr.
2017-08-10 23:34:39 +01:00
Benjamin Sago
adaa36e1c5 Integrate strict mode, use it to test file sizes
It’s a good test to be able to switch strict mode on in run.sh and not have it break anything! Now, the EXA_STRICT environment variable will toggle it on. We can even switch it off and see that it doesn’t error.
2017-08-10 18:45:26 +01:00
Benjamin Sago
dbebd60c4e Extract var_os and use the mock to test
Some of the deduce functions used to just blatantly call std::env::var_os and not care, introducing global state into a module that was otherwise nice and functional and self-contained. (Well, almost. There’s still terminal width.)

Anyway, this made it hard to test, because we couldn’t test it fully with this global dependency in place. It *is* possible to work around this by actually setting the environment variables in the tests, but this way is more self-documenting.

With this in place, we can start to unit test things like deriving the view by passing in what the $COLUMNS environment variable should be, and that’s one of the first things checked.

src/options/mod.rs *almost* has all its tests moved to where they should be!
2017-08-10 17:54:28 +01:00
Benjamin Sago
532ebbc591 Only complain about long options in strict mode
Fixes #152. It just puts the check behind a flag and moves the tests around.
2017-08-10 13:59:39 +01:00
Benjamin Sago
f389943bf1 New macro for testing deduce errors
Sometimes, the type in the Ok part of the Result wouldn’t implement PartialEq, so the first macro (which uses assert_eq) won’t work. In these cases, this new macro can be used instead, which just unwraps the Err’s contents. In other cases, it can shave off a ) at the end of a few lines.
2017-08-10 13:59:09 +01:00
Benjamin Sago
6755ee6ae9 Extract table columns into a struct
The table Options struct is roughly half runtime configuration and half flags to select which columns to display The column fields might as well be in their own struct, and now that the ‘for_dir’ function doesn’t use SizeFormat, it can be moved to Columns.
2017-08-09 22:25:16 +01:00
Benjamin Sago
6b309d5cfc Make SizeFormat lenient, and add tests
This changes the SizeFormat option parser from its old, strict-by-default behaviour (where passing both --bytes and --binary would be an error) to the new, use-the-last-argument behaviour (where passing --bytes --binary would use --binary because it came later).

Doing this meant adding functionality to Matches so that it could return *which* argument matched. Previously, the order of --bytes and --binary didn’t matter, because they couldn’t both be present, but now it does.
2017-08-09 19:18:31 +01:00
Benjamin Sago
b2947ed590 Document and test time formats 2017-08-09 17:14:16 +01:00
Benjamin Sago
0b87392fd4 Decouple assert_eq! and assert_parses
The assert_parses function was problematic because it insisted on using assert_eq! to check its contents. This won’t work for any type we want to test that doesn’t implement PartialEq, such as TimeFormat, which holds references to years and date strings and other such.

To go about fixing this, the first step is to change that function so it only does the initial processing, rather than the assertion, which is now done outside of it in the test macros instead.
2017-08-09 13:41:07 +01:00
Benjamin Sago
ff497b52e5 Be stricter in strict mode
Now the code actually starts to use the Strictness flag that was added in the earlier commit! Well, the *code* doesn’t, but the tests do: the macros that create the test cases now have a parameter for which tests they should run. It’s usually ‘Both’ for both strict mode and default mode, but can be specified to only run in one, for when the results differ (usually when options override one another)

The downside to strict mode is that, now, *any* call to `matches.has` or `matches.get` could fail, because an option could have been specified twice, and this is the place where those are checked for. This makes the code a little less ergonomic in places, but that’s what the ? operator is for. The only place this has really had an effect is in `Classify::deduce`, which used to just return a boolean but can now fail.

In order to more thoroughly test the mode, some of the older parts of the code can now act more strict. For example, `TerminalColours::deduce` will now use the last-given option rather than searching for “colours” before “colors”.

Help and Version continue doing their own thing.
2017-08-09 09:21:29 +01:00
Benjamin Sago
d97f603ee3 Make these tests less long 2017-08-08 09:20:46 +01:00
Benjamin Sago
00379cce63 Thread Strictness through the parser
The value is ignored, but this broke quite a lot of tests that assumed MatchedFlags had only one field.

Parsing tests have to have OsStr flags because I couldn’t get that part working right, but in general, some tests now re-use common functionality too.
2017-08-08 09:18:17 +01:00
Benjamin Sago
c1e206669e Give IgnorePatterns a better interface
This commit gives IgnorePatterns a bunch of constructor methods that mean its option-parsing sister file doesn’t need to know that it’s a vec of glob patterns inside: it can work with anything that iterates over strings. Now, the options module doesn’t need to know about the glob crate.
2017-08-07 09:16:56 +01:00
Benjamin Sago
89540edb22 Allow xattrs to be shown in --tree without --long
This restriction was originally only there because a standalone --tree wasn’t a thing. Now it’s there, there’s no reason to forbid the combination.
2017-08-06 12:02:17 +01:00
Benjamin Sago
b5bcf22612 Merge remote-tracking branch origin/option-pars-ng
This merges in exa’s own new options parser, which has the following features:

- You can specify an option twice and it’ll use the second one, making aliases usable for defaults (fixes #144)
- Lets arguments be specified more than once (fixes #125)

Strict mode is not done yet; I just wanted to merge this in because it’s been a while, and there’s work that needs to be done on master so I don’t want them drifting apart any further.

It’s likely that you’ll find cases where multiple arguments doesn’t work or where the wrong value is being used. There aren’t tests for *everything* yet, and it still uses global environment variables.

# Conflicts:
#	src/options/view.rs
2017-08-05 21:34:57 +01:00
Benjamin Sago
4289f4d27e Specify that we need the width of stdout
The term_size crate introduced in #237 did things *slightly* differently than exa: it tried to get the terminal width of stdout, stderr, and stdin. This broke some tests that only redirected stdout.
2017-08-05 20:26:13 +01:00
Benjamin Sago
6759a5f97e Temporarily hush warnings 2017-08-05 19:56:42 +01:00
Benjamin Sago
7cb9a43541 Extract version info into its own struct
Now it’s more like help. There aren’t any other fields in its struct at the moment, but there will be in the future (listing the features, and extremely colourful vanity mode)
2017-08-05 19:46:47 +01:00
Benjamin Sago
411bdc4321 These help fields don’t need to be pub 2017-08-05 19:45:55 +01:00
Benjamin Sago
cdad6bb960 Make building the matches more bearable
Now, building the two result vectors doesn’t have to go through at least one field.
2017-08-05 19:15:27 +01:00
Benjamin Sago
9872eba821 Separate the matched flags from the free strings
Originally, both the matched flags and the list of free strings were returned from the parsing function and then passed around to every type that had a ‘deduce’ method. This worked, but the list of free strings was carried around with it, never used.

Now, only the flags are passed around. They’re in a new struct which has the methods the Matches had.

Both of Matches’s fields are now just data, and all of the methods on MatchedFlags don’t ignore any fields, so it’s more cohesive, at least I think that’s the word.

Building up the MatchedFlags is a bit more annoying though because the vector is now hidden behind a field.
2017-08-05 19:11:00 +01:00
Benjamin Sago
0456e7cfbd Document and organise the parser module 2017-08-05 17:46:38 +01:00
Benjamin Sago
3331feaee8 Turning off unused_variables revealed a warning 2017-08-05 15:40:15 +01:00
Benjamin Sago
b46fd1e32f Extract help checking and its tests 2017-08-05 14:33:32 +01:00
Benjamin Sago
82e6fa2352 Add tests for dir_option
One of the previous tests started to fail, because it was working when it shouldn’t have! It worked up until now because I forgot to flag --level as taking an argument, and “--level 4” still worked with 4 as a filename. So there’s now an early check for that functionality that got lost somewhere.
2017-08-05 13:57:20 +01:00
Benjamin Sago
f86c49cd4a Avoid early return 2017-08-05 11:55:41 +01:00
PJB3005
f249c8528b Use term_size crate to fetch terminal size.
Should be cross-platform, one step closer to Windows support.
2017-08-05 08:09:26 +02:00
Benjamin Sago
06157fdedd Add some tests for the time flags
Apparently I forgot to give the --time flag an argument, and this wasn’t actually covered by any of the xtests! Well, it’s tested now.

I’m not sure how to handle multiple --time arguments.
2017-07-26 23:37:58 +01:00
Benjamin Sago
817c7d2318 Add tests for size format 2017-07-26 23:06:08 +01:00
Benjamin Sago
adca0d3629 Add test for ignoring globs 2017-07-26 21:29:49 +01:00
Benjamin Sago
a2cd39e0a9 Fix --tree --all
Fixes #193. --all was treated the same as --all --all; now it’s treated differently.
2017-07-26 21:14:05 +01:00
Benjamin Sago
0831573669 Add tests for dot filters 2017-07-26 21:01:22 +01:00
Benjamin Sago
bc5c0194b4 Add tests for sort field
**
2017-07-26 20:53:57 +01:00
Benjamin Sago
45e1cb77a4 Streamline parser tests 2017-07-26 20:33:59 +01:00
Benjamin Sago
2d1f462bfa Switch to the new options parser
This commit removes the dependency on the ‘getopts’ crate entirely, and re-writes all its uses to use the new options parser instead.

As expected there are casualties galore:

- We now need to collect the options into a vector at the start, so we can use references to them, knowing they’ll be stored *somewhere*.
- Because OsString isn’t Display, its Debug impl gets used instead. (This is hopefully temporary)
- Options that take values (such as ‘sort’ or ‘time-style’) now parse those values with ‘to_string_lossy’. The ‘lossy’ part means “I’m at a loss for what to do here”
- Error messages got a lot worse, but “--tree --all --all” is now a special case of error rather than just another Misfire::Useless.
- Some tests had to be re-written to deal with the fact that the parser works with references.
- ParseError loses its lifetime and owns its contents, to avoid having to attach <'a> to Misfire.
- The parser now takes an iterator instead of a slice.
- OsStrings can’t be ‘match’ patterns, so the code devolves to using long Eq chains instead.
- Make a change to the xtest that assumed an input argument with invalid UTF-8 in was always an error to stderr, when that now in fact works!
- Fix a bug in Vagrant where ‘exa’ and ‘rexa’ didn’t properly escape filenames with spaces in.
2017-07-26 17:48:18 +01:00
Benjamin Sago
5b1966d261 Move filter and dir_action from options to fs
This commit moves the definitions of Filter and DirAction from the options module to the fs module, but leaves the parts that actually have to do with option parsing alone.

Now, the options module shouldn’t define any types that get used elsewhere in the program: it only adds functionality to types that already exist.
2017-07-24 08:34:50 +01:00
Benjamin Sago
8d96be7f6a Document the parsing decisions
Even though these can’t actually be viewed with `cargo doc` yet, they’re still good to have around.
2017-07-22 18:06:05 +01:00
Benjamin Sago
5227f09f5b Macro-ify the matching tests 2017-07-13 11:51:58 +01:00
Benjamin Sago
53dc370a41 Search for long options through matches
Casualty here was that you can’t have static values reference one another directly, so the static args slice had to be turned into a slice *of references* rather than of values. No big deal, just have to write & a few more times.
2017-07-13 11:51:50 +01:00
Benjamin Sago
e08d7fe524 Test for unknown arguments 2017-07-13 10:21:10 +01:00
Benjamin Sago
0e944d7b74 Macroify parser tests 2017-07-13 10:12:38 +01:00
Benjamin Sago
c9f6c45040 Add missing short arg functionality 2017-07-13 00:51:05 +01:00
Benjamin Sago
c41005a121 Change a bunch of variable names 2017-07-12 23:17:43 +01:00
Benjamin Sago
9bbe2d9816 Throw error immediately on lookup
Every time looking up an argument fails, it returns an error. We might as well just move this into the lookup function.
2017-07-12 22:59:04 +01:00
Benjamin Sago
c18302e46e This function was used in both 2017-07-12 22:49:10 +01:00
Benjamin Sago
62b85e3e93 Add some tests for split_equals 2017-07-12 22:47:17 +01:00
Benjamin Sago
bf643c65fe Start work on our own options parser
All the tests pass, but only half the functionality is there right now.
2017-07-12 12:03:07 +01:00
Benjamin Sago
c29170e345 Get the list of file extensions from the Options
The FileExtensions in the FileName is now a reference to the one in the original FileStyle, which gets put there in the options module.

This allows the extensions to be derived from the user, somehow, in the future when that part’s done.
2017-07-10 14:01:38 +01:00
Benjamin Sago
0d613652a7 Replace FileName::new with a factory
The new FileStyles value will contain all the fields necessary to “style” a file’s name. Right now this is only the Classify field, but there can be more later. The benefit of this is that when we add more, we won’t need to update all the places where file names are displayed.
2017-07-08 12:11:11 +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
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
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
7e302718fe Update the docs where it counts 2017-06-29 13:24:55 +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
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
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
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
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
e4e603b4ee There’s more to erroneousness than an exit code 2017-06-23 22:12:21 +01:00
Benjamin Sago
c5b18d0f6b Remove extra newline from help text 2017-06-23 21:25:55 +01:00
Benjamin Sago
ded829f073 Move help generation to its own function 2017-06-23 21:22:39 +01:00
Benjamin Sago
5537dd9b99 Static lifetime elision constants 2017-05-19 09:23:27 +01:00
Benjamin Sago
de60b95850 Don’t core dump when given invalid UTF-8 arguments
By parsing OsStrings rather than Strings, it’s the getopts crate that’s doing the UTF-8 checking rather than us, so if one of them isn’t valid, it’ll just fail to parse rather than crash exa.

Also, save a few allocations here and there.
2017-05-19 00:08:13 +01:00
Benjamin Sago
2f79b4db03 Start using new shorthand object field syntax 2017-05-18 22:43:32 +01:00
Benjamin Sago
510d2f7a76 --help and --version should have exit code 0
This makes it possible to use them in scripts. Also, I couldn’t find any other program returned a different error code! So it’s being changed to 0.

Fixed #180.
2017-05-17 21:01:12 +01:00
Benjamin Sago
205f18e848 It looks like you’re writing a letter 2017-05-07 17:39:01 +01:00
Benjamin Sago
e916097e0e Similarly, turn Classify into an enum 2017-05-07 15:31:00 +01:00
Benjamin Sago
e2f73927c7 Make all the option descriptions the same
The old option descriptions were all written at different times, and needed some consistency. This makes everything consistent between the help text, README, man page, and shell completions, and fixes some mistakes made when writing them.

This also adds the missing options to the man page, fixing #175.
2017-05-06 23:00:45 +01:00
TSUYUSATO Kitsune
e81b83b4ac Implement -F/--classify option 2017-04-14 07:27:37 +09:00
Daniel Lockyer
79b4f1a6ee Switch to better handling method 2017-03-31 17:12:01 +01:00
Daniel Lockyer
ec84f16da7 Collapse down similar branches of match-statement 2017-03-31 17:11:49 +01:00
Daniel Lockyer
e059fb5ba7 Remove unnecessary reference 2017-03-31 17:09:32 +01:00
Benjamin Sago
3bce55f569 Run Untry over the entire source tree 2017-03-26 17:35:50 +01:00
Ben S
0ffb331976 Wire up the colour-scale option 2016-10-30 16:42:33 +00:00
Ben S
86065f832d File size colours on a scale
This adds an option (always on at the moment) to use a colour scale of green to yellow to orange for the file size field instead of always green. See #65.
2016-10-30 15:50:09 +00:00
Ben S
93f8ad27dc Remember to add ignore-glob to the help 2016-10-30 14:47:38 +00:00
Ben S
95596297a9 Basic glob ignoring
See #97 and recently #130 too.

This allows the user to pass in options such as "--ignore '*.pyc'" to not list any files ending in '.pyc' in the output. It uses the Rust glob crate and currently does a simple split on pipe, without any escaping, so it’s not really *complete*, but is at least something.
2016-10-30 14:43:33 +00:00
Ben S
a6712994c5 Make the views non-Copy
This has to be done for when ignore patterns get introduced and have to be stored in a Vec.
2016-10-30 14:31:25 +00:00
Brandon W Maister
7e15e0dd49 Add legal values to error messages
Now when you do `--sort time` instead of saying "unknown option --sort
time" it will say "unknown options '--sort time' (choices: name...)"
with all legal options.

This also adds the legal values to the default help text.
2016-08-28 21:56:32 -04:00
Ben S
331d5ea724 Rename underscored lifetimes
See https://github.com/rust-lang/rfcs/pull/1177
2016-06-11 13:35:40 +01:00
Benjamin Sago
476406f43b Remove unused argument 2016-04-17 21:01:30 +01:00
Benjamin Sago
78ff651326 Remove unnecessary .to_string()s from option tests 2016-04-17 20:56:06 +01:00
Benjamin Sago
e9e1161cec Split up the options module
The original options was becoming a bit unwieldy, and would have been even more so if I added the same amount of comments. So this commit splits it up.

There's no extra hiding going on here, or rearranging things within the module: (almost) everything now has to be marked 'pub' to let other sub-modules in the new options module to see it.
2016-04-17 20:38:37 +01:00