@@ -422,13 +422,11 @@ fn run_repl(workdir string, vrepl_prefix string) int {
422422 }
423423 continue
424424 }
425- // Save the source only if the user is printing something,
426- // but don't add this print call to the `lines` array,
427- // so that it doesn't get called during the next print.
428425 if r.line.starts_with ('=' ) {
429426 r.line = 'println(' + r.line[1 ..] + ')'
430427 }
431428 if r.line.starts_with ('print(' ) || r.line.starts_with ('println(' ) {
429+ // >>> println('hello')
432430 source_code := r.current_source_code (false , false ) + '\n ${r.line} \n '
433431 os.write_file (temp_file, source_code) or { panic (err) }
434432 s := repl_run_vfile (temp_file) or { return 1 }
@@ -440,6 +438,17 @@ fn run_repl(workdir string, vrepl_prefix string) int {
440438 r.lines << r.line
441439 }
442440 }
441+ } else if r.line.contains ('os.input(' ) {
442+ // >>> s := os.input('name: ')
443+ prompt_str := r.line.all_after ('os.input(' ).all_before (')' ).trim ('\' "' )
444+ line_t := r.get_one_line (prompt_str) or { break }.trim_right ('\n ' )
445+ trans_line := r.line.all_before ('os.input(' ) + "'${line_t} '"
446+ source_code := r.current_source_code (false , false ) + '\n ${trans_line} \n '
447+ os.write_file (temp_file, source_code) or { panic (err) }
448+ s := repl_run_vfile (temp_file) or { return 1 }
449+ if s.exit_code == 0 {
450+ r.lines << trans_line
451+ }
443452 } else {
444453 mut temp_line := r.line
445454 func_call , fntype := r.function_call (r.line)
0 commit comments