File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11
2+ use std:: process;
3+ use std:: fs;
4+ use std:: io;
5+
26pub fn main ( filename : & str ) {
3- println ! ( "looks like {} is the file" , filename) ;
7+ let contents : String ;
8+ match fs:: read_to_string ( filename) {
9+ Ok ( file_contents) => contents = file_contents,
10+ Err ( e) => {
11+ eprintln ! ( "Error reading file: {}" , e) ;
12+ process:: exit ( 1 ) ;
13+ } ,
14+ }
15+ run_file ( contents) ;
16+ }
17+
18+ fn run_file ( contents : String ) {
19+ for line in contents. lines ( ) {
20+ run_line ( line. to_string ( ) ) ;
21+ }
422}
523
624pub fn run_line ( line : String ) {
Original file line number Diff line number Diff line change @@ -2,6 +2,7 @@ use crate::code;
22use std:: io:: { self , Write } ;
33
44pub fn main ( ) {
5+ println ! ( "RustPython-v2 v1.0.0" ) ;
56 loop {
67 execution ( ) ;
78 }
Original file line number Diff line number Diff line change @@ -2,6 +2,7 @@ mod code;
22mod ie;
33
44use clap:: Parser ;
5+ use std:: io;
56
67#[ derive( Parser ) ]
78struct Args {
You can’t perform that action at this time.
0 commit comments