Commit Graph

62 Commits

Author SHA1 Message Date
Victor Song
d24ca084a3 Use single char pattern for better performance 2023-02-24 18:29:37 -05:00
Victor Song
1b844a8dfa Change pub_enum_variant_names lint to enum_variant_names 2023-02-24 18:29:37 -05:00
Victor Song
cd715a6e00 Safely derive Eq whenever we derive PartialEq 2023-02-24 18:29:37 -05:00
Chester Liu
23a1c8a41f Merge branch 'master' into chesterliu/dev/win-support 2021-05-15 22:03:21 +08:00
ariasuni
045172bd9e Fix all remaining clippy warnings
- Allow clippy::cast_*: generated warnings are mostly useless
- Fix the other warnings so using clippy is actually useful
2021-05-08 18:09:35 +02:00
Christian Göttsche
61ec153bcd Cleanup clippy warnings
warning: explicit lifetimes given in parameter types where they could be elided (or replaced with `'_` if needed by type declaration)
 --> src/output/escape.rs:4:1
  |
4 | pub fn escape<'a>(string: String, bits: &mut Vec<ANSIString<'a>>, good: Style, bad: Style) {
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  |

warning: this lifetime isn't used in the function definition
 --> src/output/escape.rs:4:15
  |
4 | pub fn escape<'a>(string: String, bits: &mut Vec<ANSIString<'_>>, good: Style, bad: Style) {
  |               ^^
  |

warning: single-character string constant used as pattern
   --> src/output/table.rs:310:41
    |
310 |                     if file.starts_with(":") {
    |                                         ^^^ help: try using a `char` instead: `':'`
    |

warning: single-character string constant used as pattern
   --> src/output/table.rs:310:41
    |
310 |                     if file.starts_with(":") {
    |                                         ^^^ help: try using a `char` instead: `':'`
    |

warning: methods called `new` usually return `Self`
  --> src/output/render/git.rs:38:5
   |
38 |     fn new(&self) -> Style;
   |     ^^^^^^^^^^^^^^^^^^^^^^^
   |

warning: this lifetime isn't used in the function definition
  --> src/output/icons.rs:40:22
   |
40 | pub fn iconify_style<'a>(style: Style) -> Style {
   |                      ^^
   |

warning: lint `clippy::find_map` has been removed: this lint has been replaced by `manual_find_map`, a more specific lint
  --> src/main.rs:11:10
   |
11 | #![allow(clippy::find_map)]
   |          ^^^^^^^^^^^^^^^^
   |

warning: redundant else block
   --> src/fs/dir.rs:124:18
    |
124 |               else {
    |  __________________^
125 | |                 return None
126 | |             }
    | |_____________^
    |

warning: redundant else block
  --> src/options/view.rs:60:18
   |
60 |               else {
   |  __________________^
61 | |                 // the --tree case is handled by the DirAction parser later
62 | |                 return Ok(Self::Details(details));
63 | |             }
   | |_____________^
   |

warning: all variants have the same postfix: `Bytes`
   --> src/output/table.rs:170:1
    |
170 | / pub enum SizeFormat {
171 | |
172 | |     /// Format the file size using **decimal** prefixes, such as “kilo”,
173 | |     /// “mega”, or “giga”.
...   |
181 | |     JustBytes,
182 | | }
    | |_^
    |

warning: all variants have the same postfix: `Bytes`
   --> src/output/table.rs:171:1
    |
171 | / pub enum SizeFormat {
172 | |
173 | |     /// Format the file size using **decimal** prefixes, such as “kilo”,
174 | |     /// “mega”, or “giga”.
...   |
182 | |     JustBytes,
183 | | }
    | |_^
    |

warning: useless use of `format!`
   --> src/options/mod.rs:181:50
    |
181 |               return Err(OptionsError::Unsupported(format!(
    |  __________________________________________________^
182 | |                 "Options --git and --git-ignore can't be used because `git` feature was disabled in this build of exa"
183 | |             )));
    | |_____________^ help: consider using `.to_string()`: `"Options --git and --git-ignore can't be used because `git` feature was disabled in this build of exa".to_string()`
    |

warning: stripping a prefix manually
   --> src/fs/filter.rs:287:33
    |
287 |         if n.starts_with('.') { &n[1..] }
    |                                 ^^^^^^^
    |

warning: case-sensitive file extension comparison
  --> src/info/filetype.rs:24:19
   |
24 |         file.name.ends_with(".ninja") ||
   |                   ^^^^^^^^^^^^^^^^^^^
   |
2021-04-30 15:37:31 +02:00
skyline75489
8ad46e2ee5 Merge branch 'master' into chesterliu/dev/win-support 2021-04-03 21:12:19 +08: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
Chester Liu
0ea8f17b22 Clean 2021-03-31 11:04:11 +08:00
Benjamin Sago
96e3f3d8d3
Merge pull request #818 from PatriotRossii/feature/determine_time_zone
Update determine_time_zone according to GNU manual
2021-03-30 14:49:48 +01:00
Chester Liu
00f97a9738 Mimic 'Mode' in gci 2021-03-30 17:13:00 +08:00
Chester Liu
78a3bc9838 Merge branch 'master' into chesterliu/dev/win-support 2021-03-30 11:58:39 +08:00
Chester Liu
33dd8fd2ca Clean 2021-03-26 20:34:16 +08:00
Chester Liu
5503e4756e Clean 2021-03-26 18:45:52 +08:00
Chester Liu
31583691d5 Timestamps 2021-03-26 18:40:22 +08:00
Chester Liu
aeb4a679e8 It actually works 2021-03-26 17:47:18 +08:00
Chester Liu
e9d0af0343 Restore more 2021-03-26 16:53:31 +08:00
Chester Liu
0e8a4582d0 Restore 2021-03-26 16:50:34 +08:00
Chester Liu
6a642d0f32 merge 2021-03-26 16:37:17 +08:00
PatriotRossii
4e5e2ce8f0
Replace "replace" with "replacen" 2021-03-25 11:20:11 +05:00
PatriotRossii
5743e6d8e3
Replace strip_prefix with replace 2021-03-24 19:05:38 +05:00
PatriotRossii
57cf0f1b23 Update determine_time_zone according to GNU manual 2021-03-24 17:36:13 +05: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
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
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
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
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
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
8b852cb201
Merge pull request #725 from kbravh/tz-variable-patch
Update determine_time_zone function to check TZ
2020-10-08 22:37:00 +01:00
Benjamin Sago
dbbc4e465b
Merge pull request #704 from LarsHaalck/master
Add --octal-permissions argument
2020-10-08 22:14:38 +01:00
Karey Higuera
5be0286749 deconstruct the TZ environment variable instead of unwrapping 2020-09-03 08:49:51 -04:00
Karey Higuera
e8d69fc5e8 Update determine_time_zone function to check TZ
Instead of defaulting immediately to /etc/filename for the timezone, we can first check whether the TZ environment variable is set. If so, we can pull the corresponding timezone file from /usr/share/zoneinfo. Closes #453.
2020-08-26 19:31:48 -04: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
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
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
ariasuni
56717c7336 Add “changed” sort option, to replace old incorrect “created” 2019-03-23 17:23:40 +01:00
ariasuni
b0da0c9055 Use correct metadata for created time 2019-03-23 17:18:18 +01:00
Thibaut Brandscheid
755876e9b6 fix most clippy warnings 2018-06-19 17:17:39 +02:00
Benjamin Sago
558b13880b Don’t pass Dirs to the Table
A Table now doesn’t need to know about (or even import) Dir, because we can just not pass the Git reference in if it shouldn’t be using it.
2017-09-01 22:52:13 +01:00
Benjamin Sago
f3c7fa500f Fix TableOptions Debug
The only field we can really show is the list of columns, and that happened to be useful this one time, so it might as well get shown!
2017-09-01 22:48:42 +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
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