Commit Graph

250 Commits

Author SHA1 Message Date
Benjamin Sago
f8df02dae7 Batch source formatting
I read through every file and applied a couple of rustfmt suggestions. The brace placement and alignment of items on similar lines has been made consistent, even if neither are rustfmt's default style (a file has been put in place to enforce this). Other changes are:

• Alphabetical imports and modules
• Comma placement at the end of match blocks
• Use newlines and indentation judiciously
• Spaces around associated types
• Spaces after negations (it makes it more clear imho)
• Comment formatting
• Use early-returns and Optional `?` where appropriate
2020-10-10 20:02:55 +01:00
Benjamin Sago
c3c39fee0a Various misc clippy fixes 2020-10-10 15:57:40 +01:00
Benjamin Sago
a25cfe765d Remove some enum glob imports
These are holdovers from how I used to write Rust ("back in the day" of 2014). There are still some places in the code where I think it's worth glob-importing enums, but not these places.
2020-10-10 15:46:39 +01:00
Benjamin Sago
f0c139ca68 Better referencing
This commit makes changes to the way variables are referenced:

• Make types Copy when possible
• Make methods take `self` instead of `&self` where possible (trivially_copy_pass_by_ref)
• Remove unnecessary borrowing (needless_ref)
• Remove unnecessary cloning (clone_on_copy)
• Remove `ref` from match arms where possible (new Rust match ergonomics)
2020-10-10 15:30:19 +01:00
Benjamin Sago
70a30ed683 The Selfening
This commit uses Clippy to fix all the 'use_self' warnings. Using Self instead of the type name has been good Rust style for a while now, and it's become the style I'm used to seeing.
2020-10-10 13:55:26 +01:00
Benjamin Sago
04e2d4c692 Just straight-up roll our own logger
This commit removes the env_logger dependency, replacing it with a simple implementation. Doing so removes like ten other transitive dependencies that no longer need to be included in the build.

It also gains the ability to enable trace-level logging. The users crate, which contains such logging statements as of the version I published a few days ago, has been upgraded to celebrate.

Also, change the log imports to globs. I'm only interested that a file doing logging, not what level it's logging at.
2020-10-10 02:01:12 +01:00
Benjamin Sago
dbbc4e465b
Merge pull request #704 from LarsHaalck/master
Add --octal-permissions argument
2020-10-08 22:14:38 +01:00
Benjamin Sago
d901bb289c
Merge pull request #654 from ariasuni/cleaning
Clean code a bit and fix typos in code documentation
2020-10-08 21:49:20 +01:00
Lars Haalck
16046d57de
Add --octal-permissions argument
Using --octal_permissions will insert another column before the existing
permissions where permissions are encoded using octal values as
requested in #316
2020-07-24 13:47:34 +02:00
ariasuni
dba3f37b0a Fix Clippy lints 2020-05-24 21:43:55 +02:00
Kat Marchán
7f717c3af3 checkpoint 2020-05-02 19:00:06 -07:00
ariasuni
5a84953b4e Fix typos in code documentation 2020-04-19 06:54:06 +02:00
ariasuni
046af5cdd1 Use git2 instead of parsing .gitignore for --git-ignore
Fix #636
2020-04-19 05:52:35 +02:00
Benjamin Sago
490d9680c2 Merge branch 'fix-handling-maybe-unsupported-time-metadata' of https://github.com/ariasuni/exa into ariasuni-fix-handling-maybe-unsupported-time-metadata
# Conflicts:
#	src/fs/file.rs
#	src/options/filter.rs
#	src/options/view.rs
2020-01-19 16:46:51 +00:00
Benjamin Sago
eaece8cc7a
Merge branch 'master' into customize-size-scale-colours 2020-01-19 09:57:58 +00:00
Benjamin Sago
2382be7524
Merge branch 'master' into add-missing-flags-in-docs 2020-01-19 09:40:22 +00:00
Benjamin Sago
416818fda2
Merge pull request #597 from FliegendeWurst/bugfixes
Two small bugfixes
2020-01-19 00:55:58 +00:00
Benjamin Sago
1f167dda41
Merge pull request #577 from 0rvar/feature/suppress-columns
Add support for suppressing table columns
2020-01-19 00:41:27 +00:00
Benjamin Sago
8ccff86940
Merge pull request #450 from Bond-009/2018
Update to Rust 2018
2020-01-18 23:23:43 +00:00
Benjamin Sago
44664bf757
Merge pull request #289 from mqudsi/optional_args
Optional args support
2020-01-18 23:22:17 +00:00
Orvar Segerström
250104c9da Add new suppress flags to --help 2019-12-23 12:08:03 +01:00
ariasuni
a636d08f8b Fix handling of potentially unsupported time metadata
- Checking on a directory doesn’t tell us if supported elsewhere
(some filesystems, like tmpfs, don’t support created time)
- We want to be able to display a column even if some subfiles or
subdirectories don’t support it

So now if unsupported a time of zero is used, and displayed as `-`
2019-12-20 05:37:29 +01:00
Maarten de Vries
3ef6195ffd Allow customizing size scale colours.
Also adjust the selection of the colour depending on the scale used.
 * With decimal prefixes colours change on powers of 1000.
 * With binary or no prefixes colours change on powers of 1024.
2019-11-17 16:49:51 +01:00
ecanja
aded70c98e Add missing flags in documentation files
- Update completions
  - fish		(-D)
  - zsh			(-D, --changed)
- Update man page	(--changed)
- Update README		(-F, --changed, --icons)
- Update help text	(--changed)
2019-11-12 01:18:51 +01:00
FliegendeWurst
6010ed5213
Use the long view when stdout isn't a terminal and a long grid view was requested (fixes #522) 2019-10-12 11:58:31 +02:00
Orvar Segerström
925f5173c1 Add support for suppressing table columns 2019-08-29 14:34:30 +02:00
Bond_009
f599c7ce93 Update to Rust 2018 2019-07-19 20:40:21 +02:00
Oleksii Filonenko
58c821be6e
Add documentation for --icons flag
- Update completions
  - fish
  - zsh
- Update man page
- Update help text
2019-07-19 09:58:50 +03:00
Benjamin Sago
9497b30b33 Merge branch 'glyphs' of https://github.com/asoderman/exa into asoderman-glyphs
# Conflicts:
#	src/options/flags.rs
#	src/options/view.rs
#	src/output/grid.rs
2019-07-15 03:54:31 +01:00
Benjamin Sago
9e1200f9b7 Fix failing tests 2019-07-15 03:37:05 +01:00
Benjamin Sago
faed8f9b82
Merge pull request #457 from ariasuni/fix-sorting-by-created-time
Fix sorting by created time
2019-07-15 03:30:52 +01:00
Benjamin Sago
df9b32c892 Fix a couple warnings 2019-07-13 21:17:48 +01:00
ariasuni
f0e7321506 Fix and add tests 2019-03-23 17:23:43 +01:00
ariasuni
39a49a3d36 Check if the sort field is supported by the OS 2019-03-23 17:23:43 +01:00
ariasuni
56717c7336 Add “changed” sort option, to replace old incorrect “created” 2019-03-23 17:23:40 +01:00
ariasuni
80b0d9dd0d Display if a file is ignored by git 2018-11-20 18:12:38 +01:00
James Reed
7218fb4b6a
Document only-dirs option 2018-10-26 17:21:31 -06:00
James Reed
89a6e14e15
Move level option to correct group 2018-10-26 17:15:48 -06:00
Benjamin Sago
c2bb986618 Replace Default impls that use state with fns
The Default impls for DefaultFormat and LoadFormat were originally called ‘new’, to which Clippy suggested that they be changed. But as these functions change based on what the year is, a function called something other than ‘new’, like ‘load’.
2018-10-13 22:15:10 +01:00
Benjamin Sago
ecc4138d56 Merge branch 'clippy_fixes' of https://github.com/thibran/exa into thibran-clippy_fixes
# Conflicts:
#	src/options/view.rs
#	src/style/lsc.rs
2018-10-13 22:07:35 +01:00
Benjamin Sago
a4d9b5314f
Merge pull request #405 from Don42/feature_only_dirs
Flag for only showing directories
2018-09-27 21:01:15 +01:00
Marco 'don' Kaulea
33167a2282 Add short option for only-dirs 2018-07-13 17:38:36 +02:00
Marco 'don' Kaulea
054cac6b82 Add option to only display directories
This allows printing directory trees without any files, only
showing the structure.
I haven't decided on a letter for the short option.

Implements #401
2018-07-12 18:51:14 +02:00
Thibaut Brandscheid
755876e9b6 fix most clippy warnings 2018-06-19 17:17:39 +02:00
mopp
991781070e refers TIME_STYLE environment variable if it exists and the argument is not given 2018-06-15 04:38:32 +09:00
Benjamin Sago
55048f7ee2
Merge pull request #380 from kornelski/master
Replaced try!() with ?
2018-05-28 10:50:06 +02:00
Benjamin Sago
5438f949c9
Merge pull request #311 from martinlindhe/master
adjust some spelling
2018-05-28 10:47:38 +02:00
Kornel
2976b487ab Replaced try!() with ? 2018-04-18 01:16:32 +01:00
Alex Soderman
68954f9142 Added --icons for oneline mode 2018-04-01 19:00:27 -04:00
Alex Soderman
5991bd4ab7 Added icons for --long view 2018-04-01 18:28:31 -04:00
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