Commit Graph

250 Commits

Author SHA1 Message Date
Victor Song 8d03922e3b Addressed PR comments 2023-02-24 18:45:27 -05:00
Victor Song eba3646b83 Grab bag of miscellaneous fixes 2023-02-24 18:29:37 -05:00
Victor Song 72b2119a34 Simplify boolean assertions in tests 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
Mélanie Chauvel f3ca1fe6f7
Merge pull request #820 from skyline75489/chesterliu/dev/win-support
Initial support for Windows
2023-02-20 14:19:47 +01:00
TygrisIQ 863d96150d
updated the link with markdown link syntax
updated the link in the comment so it helps with generated docs
2022-07-07 15:18:04 +03:00
Chester Liu d6732aea10 Merge branch 'master' into chesterliu/dev/win-support 2022-05-06 13:22:24 +08:00
Max Zhuravsky a371c41711
[no-color] - add unit test and doc 2021-11-26 01:45:41 +03:00
Max Zhuravsky aab1d3db59
[no-color] - implement NO_COLOR support 2021-11-25 23:37:02 +03:00
Chester Liu 99d653b7fa Merge branch 'master' into chesterliu/dev/win-support 2021-10-29 15:50:54 +08:00
Chester Liu 23a1c8a41f Merge branch 'master' into chesterliu/dev/win-support 2021-05-15 22:03:21 +08:00
ariasuni 785d6ed991 Fix clippy warnings for Rust 1.53 2021-05-13 02:44:22 +02: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
Chester Liu 8f0e4ccfdd Merge branch 'master' into chesterliu/dev/win-support 2021-04-13 11:27:49 +08:00
Benjamin Sago 550f2d29c2 Add context to all option number parse errors
Fixes GH-839.
2021-04-12 21:42:45 +01:00
Benjamin Sago 31043462af Improve help text for -d flag
Fixes GH-202.
2021-04-11 23:43:36 +01:00
skyline75489 0adc5c789b Merge branch 'master' into chesterliu/dev/win-support 2021-04-06 16:13:15 +08:00
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
skyline75489 8ad46e2ee5 Merge branch 'master' into chesterliu/dev/win-support 2021-04-03 21:12:19 +08: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
Chester Liu 78a3bc9838 Merge branch 'master' into chesterliu/dev/win-support 2021-03-30 11:58:39 +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
Chester Liu e874584a55 Try to fix CI 2021-03-28 09:31:03 +08:00
Chester Liu 13b3635407 Fix tests 2021-03-26 20:28:23 +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
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