summaryrefslogtreecommitdiffstats
path: root/src/main.rs
AgeCommit message (Collapse)Author
2016-04-19Convert exa into a libraryBenjamin Sago
This commit removes the 'main' function present in main.rs, renames it to exa.rs, and puts the 'main' function in its own binary. This, I think, makes it more clear how the program works and where the main entry point is. Librarification also means that we can start testing as a whole. Two tests have been added that test everything, passing in raw command-line arguments then comparing against the binary coloured text that gets produced. Casualties include having to specifically mark some code blocks in documentation as 'tests', as rustdoc kept on trying to execute my ANSI art.
2016-04-18Change views to print to a Writer, not stdoutBenjamin Sago
This will mean that we can test exa's output as a whole, without having to rely on process or IO or anything like that.
2016-04-16Create info module with business logic routinesBenjamin Sago
Currently these routines number two: file type checking based on a file's name, and source file checking, also based on the file's name.
2016-04-16Source file rearrangementsBenjamin Sago
This commit moves file, dir, and the feature modules into one parent 'fs' module. Now there are three main 'areas' of the code: main and options, the filesystem-touching code, and the output-displaying code. It should be the case that nothing in 'output' touches 'std::fs'.
2016-04-11Fix bug where the directory name was not printedBenjamin Sago
2016-03-31Use only the time zone data present on the systemBen S
Thinking about it, it doesn't make sense to use an *external* time zone source when the program we want to compare it to, ls, uses the system one. So just use the system one. Also, handle the case where the time zone data file can't be loaded by showing the files in UTC rather than falling over and quitting.
2016-02-10Improve system time zone detectionBen S
2016-02-10Update packages to latest versionsBen S
- Users v0.5.1, which renames OSUsers to UsersCache - Locale v0.2, which returns to libc v0.1 - Datetime v0.4.2, which mimics the locale update, and puts timezone definitions in: - Zoneinfo-data, which is needed to obtain the current timezone
2015-12-20Move colours module into outputBenjamin Sago
This commit moves the colours module to be a sub-module of the output one. This makes sense because finding which colour a certain file should be is only done during output, and (I think) the only places that the `Colours` struct's fields are ever queried is from the output module. The only casualty was that the `file_colour` from the filetype module had to be moved, as determining colours is no longer part of that module - only determining filetype is. So it now reflects its name!
2015-12-17Replace Cells with growable TextCellsBenjamin Sago
A recent change to ansi-term [1] means that `ANSIString`s can now hold either owned *or* borrowed data (Rust calls this the Cow type). This means that we can delay formatting ANSIStrings into ANSI-control-code-formatted strings until it's absolutely necessary. The process for doing this was: 1. Replace the `Cell` type with a `TextCell` type that holds a vector of `ANSIString` values instead of a formatted string. It still does the width tracking. 2. Rework the details module's `render` functions to emit values of this type. 3. Similarly, rework the functions that produce cells containing filenames to use a `File` value's `name` field, which is an owned `String` that can now be re-used. 4. Update the printing, formatting, and width-calculating code in the details and grid-details views to produce a table by adding vectors together instead of adding strings together, delaying the formatting as long as it can. This results in fewer allocations (as fewer `String` values are produced), and makes the API tidier (as fewer `String` values are being passed around without having their contents specified). This also paves the way to Windows support, or at least support for non-ANSI terminals: by delaying the time until strings are formatted, it'll now be easier to change *how* they are formatted. Casualties include: - Bump to ansi_term v0.7.1, which impls `PartialEq` and `Debug` on `ANSIString`. - The grid_details and lines views now need to take a vector of files, rather than a borrowed slice, so the filename cells produced now own the filename strings that get taken from files. - Fixed the signature of `File#link_target` to specify that the file produced refers to the same directory, rather than some phantom directory with the same lifetime as the file. (This was wrong from the start, but it broke nothing until now) References: [1]: ansi-term@f6a6579ba8174de1cae64d181ec04af32ba2a4f0
2015-11-15Use lazy_static to cache datetime formatsBen S
One of those two date formats was re-compiled before any date was displayed. Now they are compiled only the first time they're used, and cached versions are used thereafter, resulting in a speedup.
2015-11-15Avoid cloning the file names vectorBen S
By taking the file names as a mutable vector, we can avoid having to allocate a new one when it’s empty. The recent changes to Options::getopts have made it more obvious that we could move the same vector out of getopts’s matches, instead of cloning it there.
2015-11-14Move many Options structs to the output moduleBen S
This cleans up the options module, moving the structs that were *only* in use for the columns view out of it. The new OptionSet trait is used to add the ‘deduce’ methods that used to be present on the values.
2015-11-04Avoid unstable c_string conversion featuresFlorian Gilcher
2015-11-04Replace unstable fs_mode by internal constantsFlorian Gilcher
2015-11-04Replace `sum` call by stable `fold(0, Add::add)`Florian Gilcher
2015-11-03Feature slice_splits and vec_resize stabilisedBen S
As of rustc 1.6.0-nightly (1a2eaffb6 2015-10-31), anyway.
2015-09-05Do not attempt to print nothingBenjamin Sago
This fixes a bug where an extra header line was printed when in --long --grid mode.
2015-09-04Make sure we check the ioctl term size resultBen S
2015-09-04Remove pad crate and unnecessary qualificationsBen S
2015-09-04Remove trivial castBen S
2015-09-03It's hardly worth giving Exa its own constructorBen S
2015-09-02Parallelise the details view!Ben S
This commit removes the threadpool in `main.rs` that stats each command-line argument separately, and replaces it with a *scoped* threadpool in `options/details.rs` that builds the table in parallel! Running this on my machine halves the execution time when tree-ing my entire home directory (which isn't exactly a common occurrence, but it's the only way to give exa a large running time) The statting will be added back in parallel at a later stage. This was facilitated by the previous changes to recursion that made it easier to deal with. There's a lot of large sweeping architectural changes. Here's a smattering of them: - In `main.rs`, the files are now passed around as vectors of files rather than array slices of files. This is because `File`s aren't `Clone`, and the `Vec` is necessary to give away ownership of the files at the appropriate point. - In the details view, files are now sorted *all* the time, rather than obeying the command-line order. As they're run in parallel, they have no guaranteed order anyway, so we *have* to sort them again. (I'm not sure if this should be the intended behaviour or not!) This means that the `Details` struct has to have the filter *all* the time, not only while recursing, so it's been moved out of the `recurse` field. - We use `scoped_threadpool` over `threadpool`, a recent addition. It's only safely used on Nightly, which we're using anyway, so that's OK! - Removed a bunch of out-of-date comments. This also fixes #77, mainly by accident :)
2015-08-26Scan for nested files on-demand, not all the timeBen S
This does a similar thing that we did with the xattrs, except with the nested files: it removes the 'this' field on File, and replaces it with a method (to_dir) that has the same effect. This means we get to remove a bunch of 'recurse' fields and parameters that really had no business being there! Now the table doesn't need to know whether it's going to need to list files recursively or not.
2015-08-25Display errors inline in the treeBen S
When tree mode is active, this will print out errors as another form of child node in the tree, instead of in one big block before any output. The 'this' field now holds the io::Result of the readdir call, rather than only a *successful* result.
2015-08-25Make Dir return an Iterator of files, not VecBen S
This is part of work to make the flow of files more iterator-able, rather than going in and out of vectors. Here, a Dir returns an iterator of files, rather than a pre-filled vector. For now, this removes the ability for error messages to be displayed. Will be added in later though!
2015-08-03Fix bug where Git repos were always queriedBen S
This is very slow (see #28) at the moment, so there's an option to switch off repo discovery. However, they were still always being queried. Now, if there's no Git option in the flags, it won't try to discover a repo.
2015-08-02Use new slice_splits functionsBen S
These replace `init()` and `tail()` which are deprecated in favour of these. In fact, it's a good thing they're deprecated, because part of the path_prefix code involved working around a call to init() that would panic otherwise - doing the same check with an `Option` is much more ergonomic.
2015-06-28Add --grid --long optionBen S
This commit adds --grid, which, when used with --long, will split the details into multiple columns. Currently this is just 2 columns, but in the future it will be based on the width of the terminal. In order to do this, I had to do two things: 1. Add a `links` parameter to the filename function, which disables the printing of the arrow and link target in the details view. When this is active, the columns get way too large, and it becomes not worth it. 2. Change the `print_table` function from actually printing the table to stdout to returning a list of `Cells` based on the table. This list then gets its width measured to calculate the width of the resulting table.
2015-06-23Use term_grid crate for grid formattingBen S
Fixes #39!
2015-06-21The feature flags wheel keeps on turning...Ben S
2015-06-17Remove a few feature flagsBenjamin Sago
2015-06-08Various unimportant style changesBen S
2015-06-05Start using threadpool crateBen S
2015-05-21StatResult::Path -> DirBen S
2015-05-16Rename 'stat' -> 'metadata'Ben S
2015-05-16Start using the libc crate from crates.ioBen S
2015-05-12Lifetime-renaming action!Ben S
2015-05-09Add colours module, and disable them sometimesBen S
Colours are now disabled when output is not to a terminal. Fixes #53! This required some internal restructuring - colours are now in their own object that gets passed around everywhere it's needed.
2015-05-07The modules don't actually need to be publicBen S
2015-05-03Use OS-defined permission bits typeBen S
2015-05-03Continue using new metadata fieldsBen S
2015-05-03Remove unused feature gatesBen S
2015-05-03Start following symlinks againBen S
This was my favourite feature, so I'm glad to see it back!
2015-05-03Re-implement no-longer-missing metadata fieldsBen S
2015-05-03Permissions are back!Ben S
2015-04-23Use unicode_width crateBen S
2015-04-23Use new io + path + fs libraries (LOTS OF CHANGES)Ben S
Exa now uses the new IO, Path, and Filesystem libraries that have been out for a while now. Unfortunately, the new libraries don't *entirely* cover the range of the old libraries just yet: in particular, to become more cross-platform, the data in `UnstableFileStat` isn't available in the Unix `MetadataExt` yet. Much of this is contained in rust-lang/rfcs#1044 (which is due to be implemented in rust-lang/rust#14711), but it's not *entirely* there yet. As such, this commits a serious loss of functionality: no symlink viewing, no hard links or blocks, or users or groups. Also, some of the code could now be optimised. I just wanted to commit this to sort out most of the 'teething problems' of having a different path system in advance. Here's an example problem that took ages to fix for you, just because you read this far: when I first got exa to compile, it worked mostly fine, except calling `exa` by itself didn't list the current directory. I traced where the command-line options were being generated, to where files and directories were sorted, to where the threads were spawned... and the problem turned out to be that it was using the full path as the file name, rather than just the last component, and these paths happened to begin with `.`, so it thought they were dotfiles.
2015-04-04Upgrade to latest RustBenjamin Sago
Still missing a few Beta features, but it compiles! - Copy requires Clone - current_dir returns a Path now - num_cpus moved to a crate
2015-03-26Move all optional features into features moduleBen S
This module provides feature-specific implementations, and also dummy implementations for when they aren't supported by the system or OS. Doing it this way limits all the #[cfg(feature)] annotations, as we can now just include the module or not.