File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -29,8 +29,20 @@ fn main() {
2929 . multiple ( true )
3030 . help ( "Give the verbosity" ) ,
3131 )
32+ . arg (
33+ Arg :: with_name ( "c" )
34+ . short ( "c" )
35+ . takes_value ( true )
36+ . help ( "run the given string as a program" ) ,
37+ )
3238 . get_matches ( ) ;
3339
40+ // Figure out if a -c option was given:
41+ if let Some ( command) = matches. value_of ( "c" ) {
42+ run_command ( & mut command. to_string ( ) ) ;
43+ return ;
44+ }
45+
3446 // Figure out if a script was passed:
3547 match matches. value_of ( "script" ) {
3648 None => run_shell ( ) ,
@@ -52,6 +64,14 @@ fn _run_string(source: &String) {
5264 }
5365}
5466
67+ fn run_command ( source : & mut String ) {
68+ debug ! ( "Running command {}" , source) ;
69+
70+ // This works around https://github.com/RustPython/RustPython/issues/17
71+ source. push_str ( "\n " ) ;
72+ _run_string ( source)
73+ }
74+
5575fn run_script ( script_file : & String ) {
5676 debug ! ( "Running file {}" , script_file) ;
5777 // Parse an ast from it:
You can’t perform that action at this time.
0 commit comments