Commit Graph

59 Commits

Author SHA1 Message Date
Kevin Ballard
15e08338d8 Remove lazy_static crate
It's not being used anymore.
2017-05-17 22:48:11 -07:00
Benjamin Sago
56d4d4c156 Also escape characters in links and headings
Doing this meant that the escaping functionality got used in three places, so it was extracted into a generalised function in its own module.

This is slighly slower for the case where escaped characters are displayed in the same colour as the displayable characters, which happens when listing a directory’s name when recursing. Optimise this, yeah?
2017-05-01 21:54:53 +01:00
Benjamin Sago
3087565c01 Merge pull request #154 from neosilky/clippy-fixes
Fix some issues indicated by clippy
2017-04-11 08:18:55 +01:00
Laurent Arnoud
8b61a3a0f2
Exit with a non-zero status on error
With `ls` from Debian coreutils 8.26-2

```
ls /bad/path
echo $? # => 2
```

Reproduced same behaviour with exa

Fix https://github.com/ogham/exa/issues/135
2017-04-01 00:10:49 +02:00
Daniel Lockyer
da3061d1b3 Replace use of .iter() with reference 2017-03-31 17:08:11 +01:00
Benjamin Sago
3bce55f569 Run Untry over the entire source tree 2017-03-26 17:35:50 +01:00
Ben S
95596297a9 Basic glob ignoring
See #97 and recently #130 too.

This allows the user to pass in options such as "--ignore '*.pyc'" to not list any files ending in '.pyc' in the output. It uses the Rust glob crate and currently does a simple split on pipe, without any escaping, so it’s not really *complete*, but is at least something.
2016-10-30 14:43:33 +00:00
Ben S
a6712994c5 Make the views non-Copy
This has to be done for when ignore patterns get introduced and have to be stored in a Vec.
2016-10-30 14:31:25 +00:00
Ben S
dcc17b1d15 This lint flag started to cause all kinds of fuss 2016-10-29 19:52:21 +01:00
Ben S
a7e3456b0d Only engage the view when there are files to show
This changes the way that views are used to display the actual lists of files. It used to pass empty vectors to the view methods, which most of the time would not print anything because there are no files to list — except when there’s a header row which gets printed for no files.

By not calling the view method at all when there’s nothing to print, exa won’t ever print extra things in the view unless it needs to for a file.

This fixes #106 “Don’t print the header if the result set is empty”
2016-10-29 19:07:43 +01:00
Gemmarx
8d25719b6b Change to put error messages into stderr 2016-07-31 04:12:03 +09:00
Benjamin Sago
110a1c716b Convert exa into a library
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-19 07:48:41 +01:00
Ben S
6457f4b577 Rename exa.rs to main.rs 2015-01-23 19:36:01 +00:00
Ben S
0e473bf37b Upgrade to latest Rust, and move options code 2015-01-23 19:27:06 +00:00
Benjamin Sago
95388e6e90 Fix header-printing logic 2015-01-13 00:35:44 +01:00
Benjamin Sago
728e7dd976 Forbid certain argument combinations 2015-01-13 00:31:30 +01:00
Benjamin Sago
3d59a48efe Make option parsing unit-testable 2015-01-12 22:47:05 +01:00
Benjamin Sago
23e5d3ce8d Allow for different types of failure 2015-01-12 22:14:27 +01:00
Benjamin Sago
3f08836c3f Move viewing code to its own module 2015-01-12 21:08:42 +01:00
Benjamin Sago
9729679f05 Main code tidy-ups 2015-01-12 20:48:07 +01:00
Benjamin Sago
d93bca8779 Make some options fields private 2015-01-12 19:44:39 +01:00
Benjamin Sago
1c5409e253 Upgrade to Rust alpha
- uint -> usize
- getopts Cargo library
- replace feature gates with unstable APIs
2015-01-12 01:31:24 +01:00
Ben S
d400231de5 Upgrade to latest Rust
Also, remove dependency on the Regex library by replacing the one place it was used with standard code that should hopefully be faster anyway.
2015-01-05 14:41:43 +00:00
Ben S
ba36d4f7f0 Library and Rust upgrades 2015-01-04 13:56:07 +00:00
Ben S
24628f97be Use number_prefix crate for number prefixes 2014-12-18 07:00:31 +00:00
Ben S
e005174577 Extract separator_width variable 2014-12-14 19:05:07 +00:00
Ben S
49c1b8ea16 Use a more compact grid view
Now the grids are optimised so each column is only as wide as its longest file name. The method could do with some optimising, but at least it works.
2014-12-14 18:30:41 +00:00
Ben S
66339e7a15 Miscellaneous little optimisations
- Prefer iter over into_iter where appropriate
- Cut down on cloning
2014-12-12 14:06:48 +00:00
Ben S
65f124fe39 Use the natord library instead of our own sorter
I'm serious, the more functionality I can use external crates for, the better.
2014-12-12 11:26:18 +00:00
Ben S
6770ac5475 Replare Unix module with users crate
Feels good turning all that code into a dependency!
2014-12-12 11:17:55 +00:00
Ben S
6134096586 Upgrade to latest Rust
I can't complain, because the breaking changes were caused by my pull request...
2014-12-02 14:20:28 +00:00
Ben S
c217dce73d Simplify width-checking code
With suggestions from helpful #rust folk. Thank you!
2014-11-26 08:23:17 +00:00
Ben S
c52625b1ce Display files on a single line if possible 2014-11-26 08:05:07 +00:00
Ben S
05dd644c92 Upgrade to latest ansi_term
Yeah, I broke my own code again.
2014-11-26 07:36:09 +00:00
Ben S
e1d3512a69 Add --help flag 2014-11-25 15:54:50 +00:00
Ben S
0b1e94a3c8 Fix bug where header line would appear twice 2014-11-25 01:31:26 +00:00
Ben S
bcaf54d7dd Add a flag to print directories as files
Also, re-use the stat result from directory-checking.
2014-11-25 01:27:26 +00:00
Ben S
cbd2f1fa37 List files and directories separately
This finally fixes the issue where trying to list a file causes a crash. Also, tidy up some of the uses of references.
2014-11-24 17:03:36 +00:00
Ben S
03ecb8c9e1 Fix bug with empty directories 2014-11-24 01:24:45 +00:00
Ben S
d7b8b230ef Remove containers from file name in grid view
What a strange bug to happen
2014-11-23 21:57:33 +00:00
Ben S
933f98d2c3 Upgrade to latest Rust nightly 2014-11-23 21:29:11 +00:00
Ben S
b0c51d93f8 Remove a few deprecated constructs
The language keeps changing when I'm not looking!
2014-09-22 18:03:47 +02:00
Ben S
527528e81f Move file-sorting code outside the view functions 2014-07-22 22:19:51 +01:00
Ben S
44a9819417 Add --oneline option
Also, rename old 'lines' view to 'details' which makes more sense
2014-07-22 20:47:30 +01:00
Ben S
cf3e32c9c1 Get terminal width for grid view (resolve #1) 2014-07-22 15:41:20 +01:00
Ben S
b1560edb85 Use string width, rather than length, to calculate column size 2014-07-21 22:05:39 +01:00
Ben S
4cbc1f063a Upgrade to latest Rust nightly
- Lifetime changes in unix.rs
- lexical_ordering -> cmp
- from_utf8_lossy got moved into String
- vec.get(n) -> vec[n]
2014-07-21 22:05:04 +01:00
Ben S
fc90f4bfc9 Don't pad the final column 2014-07-07 20:11:30 +01:00
Ben S
240cbf7b41 Add --across parameter 2014-07-07 19:18:09 +01:00
Ben S
03c51f0bfd Correctly calculate number of rows 2014-07-07 18:42:09 +01:00