File tree Expand file tree Collapse file tree 2 files changed +16
-7
lines changed Expand file tree Collapse file tree 2 files changed +16
-7
lines changed Original file line number Diff line number Diff line change @@ -276,15 +276,25 @@ impl<'a> Interpreter<'a> {
276
276
async fn run_read ( & mut self , block : & ReadBlock , _context : Context ) -> Interpretation {
277
277
let trace = block. clone ( ) ;
278
278
279
- if let Some ( message) = & block. message {
280
- println ! ( "{}" , message) ;
281
- }
279
+ println ! (
280
+ "{}" ,
281
+ match ( & block. message, block. multiline) {
282
+ ( Some ( message) , _) => message. as_str( ) ,
283
+ ( None , Some ( true ) ) => "Enter/Paste your content. Ctrl-D to save it." ,
284
+ _ => "How can i help you?" ,
285
+ }
286
+ ) ;
282
287
283
288
let buffer = match & block. read {
284
289
Value :: String ( file_path) => Ok ( read_file_to_string ( self . path_to ( file_path) ) ?) ,
285
290
Value :: Null => {
286
291
let mut buffer = String :: new ( ) ;
287
- :: std:: io:: stdin ( ) . read_line ( & mut buffer) ?;
292
+ let mut bytes_read = :: std:: io:: stdin ( ) . read_line ( & mut buffer) ?;
293
+ if let Some ( true ) = block. multiline {
294
+ while bytes_read > 0 {
295
+ bytes_read = :: std:: io:: stdin ( ) . read_line ( & mut buffer) ?;
296
+ }
297
+ }
288
298
Ok ( buffer)
289
299
}
290
300
x => Err ( Box :: < dyn Error + Send + Sync > :: from ( format ! (
Original file line number Diff line number Diff line change 1
- text:
2
- - message: How are you?
3
- read: null
1
+ message: How are you?
2
+ read: null
You can’t perform that action at this time.
0 commit comments