Skip to content

Commit 0ffb331

Browse files
committed
Wire up the colour-scale option
1 parent 86065f8 commit 0ffb331

File tree

4 files changed

+23
-16
lines changed

4 files changed

+23
-16
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ exa’s options are similar, but not exactly the same, as `ls`.
2323
- **-T**, **--tree**: recurse into subdirectories in a tree view
2424
- **-x**, **--across**: sort multi-column view entries across
2525
- **--color**, **--colour**: when to colourise the output
26+
- **--color-scale**, **--colour-scale**: colour file sizes according to their magnitude
2627

2728
### Filtering Options
2829

src/options/help.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@ DISPLAY OPTIONS
77
-R, --recurse recurse into directories
88
-T, --tree recurse into subdirectories in a tree view
99
-x, --across sort multi-column view entries across
10-
--color, --colour when to colourise the output
10+
11+
--color=WHEN, --colour=WHEN when to colourise the output (always, auto, never)
12+
--color-scale, --colour-scale colour file sizes according to their magnitude
1113
1214
FILTERING AND SORTING OPTIONS
1315
-a, --all show dot-files

src/options/mod.rs

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -49,14 +49,16 @@ impl Options {
4949
opts.optflag("?", "help", "show list of command-line options");
5050

5151
// Display options
52-
opts.optflag("1", "oneline", "display one entry per line");
53-
opts.optflag("G", "grid", "display entries in a grid view (default)");
54-
opts.optflag("l", "long", "display extended details and attributes");
55-
opts.optflag("R", "recurse", "recurse into directories");
56-
opts.optflag("T", "tree", "recurse into subdirectories in a tree view");
57-
opts.optflag("x", "across", "sort multi-column view entries across");
58-
opts.optopt ("", "color", "when to show anything in colours", "WHEN");
59-
opts.optopt ("", "colour", "when to show anything in colours (alternate spelling)", "WHEN");
52+
opts.optflag("1", "oneline", "display one entry per line");
53+
opts.optflag("G", "grid", "display entries in a grid view (default)");
54+
opts.optflag("l", "long", "display extended details and attributes");
55+
opts.optflag("R", "recurse", "recurse into directories");
56+
opts.optflag("T", "tree", "recurse into subdirectories in a tree view");
57+
opts.optflag("x", "across", "sort multi-column view entries across");
58+
opts.optopt ("", "color", "when to show anything in colours", "WHEN");
59+
opts.optopt ("", "colour", "when to show anything in colours (alternate spelling)", "WHEN");
60+
opts.optflag("", "color-scale", "use a colour scale when displaying file sizes (alternate spelling)");
61+
opts.optflag("", "colour-scale", "use a colour scale when displaying file sizes");
6062

6163
// Filtering and sorting options
6264
opts.optflag("", "group-directories-first", "list directories before other files");

src/options/view.rs

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@ impl View {
2525
pub fn deduce(matches: &getopts::Matches, filter: FileFilter, dir_action: DirAction) -> Result<View, Misfire> {
2626
use options::misfire::Misfire::*;
2727

28+
let colour_scale = || {
29+
matches.opt_present("color-scale") || matches.opt_present("colour-scale")
30+
};
31+
2832
let long = || {
2933
if matches.opt_present("across") && !matches.opt_present("grid") {
3034
Err(Useless("across", true, "long"))
@@ -34,13 +38,12 @@ impl View {
3438
}
3539
else {
3640
let term_colours = try!(TerminalColours::deduce(matches));
37-
let scale = true;
3841
let colours = match term_colours {
39-
TerminalColours::Always => Colours::colourful(scale),
42+
TerminalColours::Always => Colours::colourful(colour_scale()),
4043
TerminalColours::Never => Colours::plain(),
4144
TerminalColours::Automatic => {
4245
if dimensions().is_some() {
43-
Colours::colourful(scale)
46+
Colours::colourful(colour_scale())
4447
}
4548
else {
4649
Colours::plain()
@@ -85,13 +88,12 @@ impl View {
8588
let other_options_scan = || {
8689
let term_colours = try!(TerminalColours::deduce(matches));
8790
let term_width = try!(TerminalWidth::deduce());
88-
let scale = true;
8991

9092
if let Some(&width) = term_width.as_ref() {
9193
let colours = match term_colours {
92-
TerminalColours::Always => Colours::colourful(scale),
94+
TerminalColours::Always => Colours::colourful(colour_scale()),
9395
TerminalColours::Never => Colours::plain(),
94-
TerminalColours::Automatic => Colours::colourful(scale),
96+
TerminalColours::Automatic => Colours::colourful(colour_scale()),
9597
};
9698

9799
if matches.opt_present("oneline") {
@@ -134,7 +136,7 @@ impl View {
134136
// fallback to the lines view.
135137

136138
let colours = match term_colours {
137-
TerminalColours::Always => Colours::colourful(scale),
139+
TerminalColours::Always => Colours::colourful(colour_scale()),
138140
TerminalColours::Never => Colours::plain(),
139141
TerminalColours::Automatic => Colours::plain(),
140142
};

0 commit comments

Comments
 (0)