@@ -54,7 +54,9 @@ impl FsRead {
5454 let is_file = ctx. fs ( ) . symlink_metadata ( & self . path ) . await ?. is_file ( ) ;
5555
5656 if is_file {
57- let relative_path = relative_path ( ctx. env ( ) . current_dir ( ) ?, & path) ;
57+ // TODO(bskiser): improve pathing display
58+ // let relative_path = relative_path(ctx.env().current_dir()?, &path);
59+ let relative_path = & path;
5860 if let Some ( ( start, Some ( end) ) ) = self . read_range ( ) ? {
5961 // TODO: file size limit?
6062 // TODO: don't read entire file in memory
@@ -166,7 +168,14 @@ impl FsRead {
166168 let is_file = self . ty . expect ( "Tool needs to have been validated" ) ;
167169
168170 if is_file {
169- queue ! ( updates, style:: Print ( format!( "Reading file: {}, " , self . path) ) ) ?;
171+ queue ! (
172+ updates,
173+ style:: Print ( "Reading file: " ) ,
174+ style:: SetForegroundColor ( Color :: Green ) ,
175+ style:: Print ( & self . path) ,
176+ style:: ResetColor ,
177+ style:: Print ( ", " ) ,
178+ ) ?;
170179
171180 let read_range = self . read_range . as_ref ( ) ;
172181 let start = read_range. and_then ( |r| r. first ( ) ) ;
@@ -175,20 +184,45 @@ impl FsRead {
175184 match ( start, end) {
176185 ( Some ( start) , Some ( end) ) => Ok ( queue ! (
177186 updates,
178- style:: Print ( format!( "from line {} to {}\n " , start, end) )
187+ style:: Print ( "from line " ) ,
188+ style:: SetForegroundColor ( Color :: Green ) ,
189+ style:: Print ( start) ,
190+ style:: ResetColor ,
191+ style:: Print ( " to " ) ,
192+ style:: SetForegroundColor ( Color :: Green ) ,
193+ style:: Print ( end) ,
194+ style:: ResetColor ,
179195 ) ?) ,
180196 ( Some ( start) , None ) => {
181- let input = if * start > 0 {
182- format ! ( "from line {} to end of file\n " , start)
197+ if * start > 0 {
198+ Ok ( queue ! (
199+ updates,
200+ style:: Print ( "from line " ) ,
201+ style:: SetForegroundColor ( Color :: Green ) ,
202+ style:: Print ( start) ,
203+ style:: ResetColor ,
204+ style:: Print ( " to end of file" ) ,
205+ ) ?)
183206 } else {
184- format ! ( "{} line from the end of file to end of file" , start)
185- } ;
186- Ok ( queue ! ( updates, style:: Print ( input) ) ?)
207+ Ok ( queue ! (
208+ updates,
209+ style:: SetForegroundColor ( Color :: Green ) ,
210+ style:: Print ( start) ,
211+ style:: ResetColor ,
212+ style:: Print ( " line from the end of file to end of file" ) ,
213+ ) ?)
214+ }
187215 } ,
188- _ => Ok ( queue ! ( updates, style:: Print ( "all lines" ) ) ?) ,
216+ _ => Ok ( queue ! ( updates, style:: Print ( "all lines" . to_string ( ) ) ) ?) ,
189217 }
190218 } else {
191- queue ! ( updates, style:: Print ( format!( "Reading directory: {}, " , self . path) ) ) ?;
219+ queue ! (
220+ updates,
221+ style:: Print ( "Reading directory: " ) ,
222+ style:: SetForegroundColor ( Color :: Green ) ,
223+ style:: Print ( & self . path) ,
224+ style:: ResetColor
225+ ) ?;
192226
193227 let depth = if let Some ( ref depth) = self . read_range {
194228 * depth. first ( ) . unwrap_or ( & 0 )
0 commit comments