Commit Graph

223 Commits

Author SHA1 Message Date
Benjamin Sago 8c34b46a22 Version output changes
• Bring what's shown in the version string in line with my other projects (URL, description, git hash and date for release-mode non-final builds only, potential for colours in the future)
• Show +git or -git depending on feature status
• Tests for the above, and for checking that the command-line flag is warned about
2021-04-03 17:41:48 +01:00
Benjamin Sago 622904d07c Fix integration tests after merged PRs
• The spaces between icons and filenames are now coloured too
• Some icons are different
• File sizes are now more accurate
• New help text, which needed a newline at the end
2021-04-01 10:19:34 +01:00
Benjamin Sago c1435411c3
Merge pull request #813 from b05902132/numeric_gid_uid
Add options for -n or --numeric-gid-uid.
2021-04-01 09:18:59 +01:00
b05902132 2f72b3ff3a Use --numeric instead of --numeric-uid-gid. 2021-03-31 21:48:59 +08:00
b05902132 53ccf18746 Add test for parsing '--numeric-uid-gid'. 2021-03-31 21:48:59 +08:00
b05902132 76f20f8b7d Add strictness check for '-n'. 2021-03-31 21:48:59 +08:00
b05902132 46a3e59e66 Some minor fixes
Co-authored-by: Mélanie Chauvel <perso@hack-libre.org>

Also add more spaces to make the descriptions of other options align that of `-n`.
2021-03-31 21:48:34 +08:00
Benjamin Sago e6edb888a0
Merge pull request #762 from ariasuni/warm-when-git-feature-is-disabled
Warm when git feature is disabled instead of ignoring flags
2021-03-29 23:51:30 +01:00
b05902132 4ea79ee11d Add options for -n or --numeric-gid-uid.
This option is only avaialable in -l.
There's test for rendering, but no test for option parsing.
(I don't understand that section of code.)
2021-03-19 09:49:17 +08:00
Stuart Carnie c946bab08e
chore: PR feedback 2021-02-28 07:48:00 +11:00
Stuart Carnie c42e0b3945
feat: New Icons and CLI argument to suppress icons 2021-02-28 07:18:17 +11:00
ariasuni 42bc34f339 Tell if exa was compiled with git support or not when using --help 2020-12-10 19:29:33 +01:00
ariasuni a740512014 Warm when git feature is disabled instead of ignoring flags
The flags --git and --git-ignore are caught early during options parsing, so no more checking for git feature is done elsewhere.

Since --git-ignore depends on git too since recently, remove it from help when git feature is disabled.

Extended attributes now don’t artificially depends on git feature being enabled.
2020-12-10 18:48:58 +01:00
Benjamin Sago 51be9f4c43 Introduce EXA_ICON_SPACING environment variable
This commit remove the extra space that was added between icons and file names in commit 128fadd, and adds an option to put them back.

Re-fixes GH-619 and fixes GH-541.
2020-10-24 19:41:07 +01:00
Benjamin Sago a1869f208e Move common icons option to file style struct
All four of the view mode command-line argument parsers tested for the --icons option. Because it was common, the behaviour has been moved to the struct that handles file styles, meaning it can be parsed in one place.

This is a better place for it, as the icons are to do with the file name, not the view. It also means that the lines view has no options left for it, which is fitting.
2020-10-23 23:57:10 +01:00
Benjamin Sago fd730e436c Make View command-line args position-dependent
This commit changes the way the View (long mode, lines mode, grid mode, etc) is parsed from the command-line arguments.

Previously, it checked for long and long-grid, then tree, then lines, then grid, in that order, no matter which order the arguments were given in on the command-line. Now, it bases the view on whichever argument comes last in the list.

Unfortunately, the options-parsing code for Views is getting really complicated, but I can't see a way to simplify it while retaining the existing functionality.

It also links the parsing of DirAction to the result of parsing the View, so that you can't use tree mode if your view isn't Details. This is to fix an issue where `exa --tree --oneline` would just emit ".", because the DirAction was treating directories as files, and the argument was ".", and the View made it use lines view. Now, the --tree is ignored, as the view isn't Details.

Fixes GH-407 and GH-583.
2020-10-23 23:04:22 +01:00
Benjamin Sago 3419afa7cf Massive theming and view options refactor
This commit significantly refactors the way that options are parsed. It introduces the Theme type which contains both styling and extension configuration, converts the option-parsing process into a being a pure function, and removes some rather gnarly old code.

The main purpose of the refactoring is to fix GH-318, "Tests fail when not connected to a terminal". Even though exa was compiling fine on my machine and on Travis, it was failing for automated build scripts. This was because of what the option-parsing code was trying to accomplish: it wasn't just providing a struct of the user's settings, it was also checking the terminal, providing a View directly.

This has been changed so that the options module now _only_ looks at the command-line arguments and environment variables. Instead of returning a View, it returns the user's _preference_, and it's then up to the 'main' module to examine the terminal width and figure out if the view is doable, downgrading it if necessary.

The code that used to determine the view was horrible and I'm pleased it can be cut out. Also, the terminal width used to be in a lazy_static because it was queried multiple times, and now it's not in one because it's only queried once, which is a good sign for things going in the right direction.

There are also some naming and organisational changes around themes. The blanket terms "Colours" and "Styles" have been yeeted in favour of "Theme", which handles both extensions and UI colours. The FileStyle struct has been replaced with file_name::Options, making it similar to the views in how it has an Options struct and a Render struct.

Finally, eight unit tests have been removed because they turned out to be redundant (testing --colour and --color) after examining the tangled code, and the default theme has been put in its own file in preparation for more themes.
2020-10-22 22:34:00 +01:00
Benjamin Sago eb90b4d168 Ignore --across --long conflict not in strict mode
Fixes #476.
2020-10-20 22:48:05 +01:00
Benjamin Sago 85414b2a61 Very slight test cleaning
I'm not 100% on the way these tests are laid out, but it _is_ helpful to see all the test data aligned like that.
2020-10-20 22:42:04 +01:00
Benjamin Sago 86de17b788 Help text changes
This changes the --help text, and gets rid of the special behaviour for --help --long, which I thought was a really good idea at the time, but now I just think it's inconsistent and unexpected behaviour. --help should return the same help, no matter what other arguments you have typed.

Other things:
• Put --help and --version in a section
• Capitalisation consistency
• Alignment
• Move the --octal-permissions line up a bit
• Simplify the printing implementation (HelpString is now a unit struct)

This _finally_ makes all the extended tests pass.
2020-10-16 23:53:42 +01:00
Benjamin Sago 002080cde8 Clippy pedantic lints
This commit fixes a couple of Clippy warnings, and adds the list of lints we're OK with.

It does raise some important warnings, such as those to do with casting, which aren't allowed so they can be fixed later.
2020-10-13 01:46:17 +01:00
Benjamin Sago 3dc86c99ad New set of lints, and Rust 2018 idioms 2020-10-13 01:36:41 +01:00
Benjamin Sago 6f2d8cc26c Have tests use OsStrs not OsStrings 2020-10-13 00:29:49 +01:00
Benjamin Sago ed59428cbc Replace Misfire with a testable OptionsResult
This was meant to be a small change, but it spiralled into a big one.

The original intention was to separate OptionsResult and OptionsError. With these types separated, the Help and Version variants can only be returned from the Options::parse function, and the later option-parsing functions can only return success or errors.

Also, Misfire was a silly name.

As a side-effect of Options::parse returning OptionsResult instead of Result<Options, Misfire>, we could no longer use unwrap() or unwrap_err() to get the contents out. This commit makes OptionsResult into a value type, and Options::parse a pure function. It feels like it should be one, having its return value entirely dependent on its arguments, but it also loaded locales and time zones. These parts have been moved into lazy_static references, and the code still passes tests without much change.

OptionsResult isn't PartialEq yet, because the file colouring uses a Box internally.
2020-10-12 23:47:36 +01:00
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
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