@@ -4,6 +4,7 @@ use std::{env, fs, io};
44use termion:: color;
55use users:: { get_current_uid, get_user_by_uid} ;
66extern crate pretty_bytes;
7+ use ansi_term:: Style ;
78use pretty_bytes:: converter:: convert;
89
910fn main ( ) -> io:: Result < ( ) > {
@@ -24,7 +25,39 @@ fn main() -> io::Result<()> {
2425 } ;
2526 }
2627
27- for e in entries {
28+ print ! ( "{}" , Style :: new( ) . underline( ) . paint( "permissions" ) ) ;
29+ for _ in 0 ..2 {
30+ print ! ( "{}" , Style :: new( ) . underline( ) . paint( " " ) )
31+ }
32+ print ! ( " {}" , Style :: new( ) . underline( ) . paint( "size" ) ) ;
33+ for _ in 0 ..( size_count - 4 ) {
34+ print ! ( "{}" , Style :: new( ) . underline( ) . paint( " " ) )
35+ }
36+
37+ print ! ( " {}" , Style :: new( ) . underline( ) . paint( "modified" ) ) ;
38+
39+ for _ in 0 ..11 {
40+ print ! ( "{}" , Style :: new( ) . underline( ) . paint( " " ) )
41+ }
42+
43+ print ! ( " {}" , Style :: new( ) . underline( ) . paint( "user" ) ) ;
44+
45+ for _ in 0 ..( get_user_by_uid ( get_current_uid ( ) )
46+ . unwrap ( )
47+ . name ( )
48+ . to_str ( )
49+ . unwrap ( )
50+ . len ( )
51+ - 4 )
52+ {
53+ print ! ( "{}" , Style :: new( ) . underline( ) . paint( " " ) )
54+ }
55+
56+ print ! ( " {}" , Style :: new( ) . underline( ) . paint( "name" ) ) ;
57+
58+ print ! ( "\n " ) ;
59+
60+ for e in & entries {
2861 let meta = fs:: metadata ( & e) ?;
2962 let mode = meta. mode ( ) ;
3063 let user_has_write_access = mode & 0o200 ;
@@ -40,15 +73,19 @@ fn main() -> io::Result<()> {
4073 mode_count += 2 ;
4174 }
4275 if user_has_read_write_access == 384 {
43- print ! ( "{}" , color:: Fg ( color:: LightBlue ) ) ;
44- print ! ( "rw" ) ;
76+ print ! ( "{}" , color:: Fg ( color:: LightYellow ) ) ;
77+ print ! ( "r" ) ;
78+ print ! ( "{}" , color:: Fg ( color:: LightRed ) ) ;
79+ print ! ( "w" ) ;
4580 print ! ( "{}" , color:: Fg ( color:: White ) ) ;
4681 print ! ( "-" ) ;
4782 mode_count += 3 ;
4883 }
4984 if group_has_read_access == 32 {
50- print ! ( "{}" , color:: Fg ( color:: Red ) ) ;
51- print ! ( "xa" ) ;
85+ print ! ( "{}" , color:: Fg ( color:: Green ) ) ;
86+ print ! ( "x" ) ;
87+ print ! ( "{}" , color:: Fg ( color:: LightYellow ) ) ;
88+ print ! ( "a" ) ;
5289 print ! ( "{}" , color:: Fg ( color:: White ) ) ;
5390 print ! ( "-" ) ;
5491 mode_count += 3 ;
@@ -71,14 +108,8 @@ fn main() -> io::Result<()> {
71108 print ! ( " " )
72109 }
73110 print ! ( "{}" , color:: Fg ( color:: Green ) ) ;
74- print ! ( " {}" , convert( fs:: metadata( & e) ?. size( ) as f64 ) ) ;
111+ print ! ( " {}" , Style :: new ( ) . bold ( ) . paint ( convert( fs:: metadata( & e) ?. size( ) as f64 ) ) ) ;
75112
76- if let Ok ( time) = e. metadata ( ) ?. created ( ) {
77- print ! ( "{}" , color:: Fg ( color:: LightBlue ) ) ;
78- let datetime: DateTime < Utc > = time. into ( ) ;
79- print ! ( " {} " , datetime. format( "%d-%m-%Y" ) ) ;
80- print ! ( "{}" , datetime. format( "%T" ) )
81- }
82113 if let Ok ( time) = e. metadata ( ) ?. modified ( ) {
83114 print ! ( "{}" , color:: Fg ( color:: LightRed ) ) ;
84115 let datetime: DateTime < Utc > = time. into ( ) ;
@@ -89,11 +120,11 @@ fn main() -> io::Result<()> {
89120 print ! ( "{}" , color:: Fg ( color:: Yellow ) ) ;
90121 print ! (
91122 " {} " ,
92- get_user_by_uid( get_current_uid( ) )
93- . unwrap( )
94- . name( )
95- . to_str( )
96- . unwrap( )
123+ Style :: new ( ) . bold ( ) . paint ( get_user_by_uid( get_current_uid( ) )
124+ . unwrap( )
125+ . name( )
126+ . to_str( )
127+ . unwrap( ) )
97128 ) ;
98129
99130 print ! ( "{}" , color:: Fg ( color:: White ) ) ;
@@ -102,7 +133,7 @@ fn main() -> io::Result<()> {
102133 println ! ( "{}/" , & e. file_name( ) . unwrap( ) . to_str( ) . unwrap( ) ) ;
103134 } else {
104135 print ! ( "{}" , color:: Fg ( color:: LightGreen ) ) ;
105- println ! ( "{}" , & e. file_name( ) . unwrap( ) . to_str( ) . unwrap( ) ) ;
136+ println ! ( "{}" , Style :: new ( ) . bold ( ) . paint ( e. file_name( ) . unwrap( ) . to_str( ) . unwrap( ) ) ) ;
106137 }
107138 }
108139 Ok ( ( ) )
0 commit comments