|
1 | 1 | use clap::{Arg, ArgAction, Command};
|
2 |
| -use colored::*; |
3 | 2 | use flexi_logger::{detailed_format, Duplicate, FileSpec, Logger};
|
4 | 3 | use log::{error, info, warn};
|
| 4 | +use owo_colors::OwoColorize; |
5 | 5 |
|
6 | 6 | use std::{
|
7 | 7 | env,
|
@@ -372,7 +372,7 @@ fn sl() -> Command {
|
372 | 372 | "✨"
|
373 | 373 | ))
|
374 | 374 | // TODO update version
|
375 |
| - .version("1.1.1") |
| 375 | + .version("1.1.2") |
376 | 376 | .author("Leann Phydon <[email protected]>")
|
377 | 377 | .arg(
|
378 | 378 | Arg::new("colour")
|
@@ -722,8 +722,12 @@ fn print_output_long(
|
722 | 722 | let cstr = format!("{}", name_or_path.bold().truecolor(226, 120, 120));
|
723 | 723 | name.push_str(&cstr);
|
724 | 724 | } else if SPECIAL.iter().any(|it| &file_extension == it) {
|
725 |
| - let cstr = format!("{}", name_or_path.truecolor(226, 164, 120)) |
726 |
| - .on_truecolor(22, 24, 33); |
| 725 | + let cstr = format!( |
| 726 | + "{}", |
| 727 | + name_or_path |
| 728 | + .truecolor(226, 164, 120) |
| 729 | + .on_truecolor(22, 24, 33) |
| 730 | + ); |
727 | 731 | name.push_str(&cstr);
|
728 | 732 | } else if PROGRAMMING.iter().any(|it| &file_extension == it) {
|
729 | 733 | let cstr = format!("{}", name_or_path.truecolor(180, 190, 130));
|
@@ -775,43 +779,56 @@ fn print_output_long(
|
775 | 779 | perm_write.push_str(&permissions.write);
|
776 | 780 | }
|
777 | 781 |
|
778 |
| - let fsize_unit = if colour { |
779 |
| - if let Some(f) = filesize.pop() { |
780 |
| - f.truecolor(50, 170, 130) |
781 |
| - } else { |
782 |
| - "".to_string().truecolor(198, 200, 209) |
| 782 | + let mut fsize_unit = String::new(); |
| 783 | + match colour { |
| 784 | + true => { |
| 785 | + if let Some(f) = filesize.pop() { |
| 786 | + fsize_unit.push_str(&f.truecolor(50, 170, 130).to_string()) |
| 787 | + } else { |
| 788 | + fsize_unit.push_str(&"".truecolor(198, 200, 209).to_string()) |
| 789 | + } |
783 | 790 | }
|
784 |
| - } else { |
785 |
| - if let Some(f) = filesize.pop() { |
786 |
| - f.truecolor(198, 200, 209) |
787 |
| - } else { |
788 |
| - "".to_string().truecolor(198, 200, 209) |
| 791 | + false => { |
| 792 | + if let Some(f) = filesize.pop() { |
| 793 | + fsize_unit.push_str(&f.truecolor(198, 200, 209).to_string()) |
| 794 | + } else { |
| 795 | + fsize_unit.push_str(&"".truecolor(198, 200, 209).to_string()) |
| 796 | + } |
789 | 797 | }
|
790 | 798 | };
|
791 | 799 |
|
792 |
| - let fsize = if colour { |
793 |
| - if let Some(f) = filesize.pop() { |
794 |
| - f.truecolor(102, 255, 179) |
795 |
| - } else { |
796 |
| - "".to_string().truecolor(198, 200, 209) |
| 800 | + let mut fsize = String::new(); |
| 801 | + match colour { |
| 802 | + true => { |
| 803 | + if let Some(f) = filesize.pop() { |
| 804 | + fsize.push_str(&f.truecolor(102, 255, 179).to_string()) |
| 805 | + } else { |
| 806 | + fsize.push_str(&"".truecolor(198, 200, 209).to_string()) |
| 807 | + } |
797 | 808 | }
|
798 |
| - } else { |
799 |
| - if let Some(f) = filesize.pop() { |
800 |
| - f.truecolor(198, 200, 209) |
801 |
| - } else { |
802 |
| - "".to_string().truecolor(198, 200, 209) |
| 809 | + false => { |
| 810 | + if let Some(f) = filesize.pop() { |
| 811 | + fsize.push_str(&f.truecolor(198, 200, 209).to_string()) |
| 812 | + } else { |
| 813 | + fsize.push_str(&"".truecolor(198, 200, 209).to_string()) |
| 814 | + } |
803 | 815 | }
|
804 | 816 | };
|
805 | 817 |
|
806 |
| - let modified = if colour { |
807 |
| - modified.truecolor(97, 88, 111) |
808 |
| - } else { |
809 |
| - modified.truecolor(198, 200, 209) |
| 818 | + let modified = match colour { |
| 819 | + true => modified.truecolor(97, 88, 111), |
| 820 | + false => modified.truecolor(198, 200, 209), |
810 | 821 | };
|
811 | 822 |
|
812 | 823 | println!(
|
813 |
| - "{}{}{}\t{:>7}{} {:>14} {}", |
814 |
| - ftype, perm_read, perm_write, fsize, fsize_unit, modified, name, |
| 824 | + "{}{}{}\t{:>30}{} {:>35} {}", |
| 825 | + ftype, |
| 826 | + perm_read, |
| 827 | + perm_write, |
| 828 | + fsize, |
| 829 | + fsize_unit, |
| 830 | + modified.to_string(), |
| 831 | + name, |
815 | 832 | );
|
816 | 833 | }
|
817 | 834 |
|
|
0 commit comments