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> {
276276 async fn run_read ( & mut self , block : & ReadBlock , _context : Context ) -> Interpretation {
277277 let trace = block. clone ( ) ;
278278
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+ ) ;
282287
283288 let buffer = match & block. read {
284289 Value :: String ( file_path) => Ok ( read_file_to_string ( self . path_to ( file_path) ) ?) ,
285290 Value :: Null => {
286291 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+ }
288298 Ok ( buffer)
289299 }
290300 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