skipped 4 lines 5 5 #[derive(Debug)] 6 6 pub struct AppArgs { 7 7 pub script_name: String, 8 - pub forwared : String, 8 + pub forwarded : String, 9 9 pub change_dir: PathBuf, 10 10 pub command: String, 11 11 pub interactive: bool, skipped 7 lines 19 19 let mut args = AppArgs { 20 20 script_name: "".to_string(), 21 21 change_dir: PathBuf::from(env::current_dir().as_ref().unwrap()), 22 - forwared : "".to_string(), 22 + forwarded : "".to_string(), 23 23 command: "".to_string(), 24 24 interactive: false, 25 25 }; skipped 36 lines 62 62 } 63 63 } 64 64 } else { 65 - // forwared flags 66 - args.forwared .push_str(" "); 67 - args.forwared .push_str(&v); 65 + // forwarded flags 66 + args.forwarded .push_str(" "); 67 + args.forwarded .push_str(&v); 68 68 } 69 - } else if COMMANDS_TO_FORWARD.contains(&v.as_str()) { 69 + } else if args.command.is_empty() 70 + && (COMMANDS_TO_FORWARD.contains(&v.as_str()) || v == "run") 71 + { 70 72 args.command = match v.as_ref() { 71 73 "i" => "install".to_string(), 72 74 _ => v.to_string(), 73 75 }; 74 - } else if args.script_name .is_empty() { 76 + } else if ( args.command .is_empty() | | args . command = = " run " ) 77 + && args.script_name.is_empty() 78 + { 79 + args.command = "run".to_string(); 75 80 args.script_name = match v.as_ref() { 76 81 "t" => "test".to_string(), 77 82 _ => v.to_string(), skipped 3 lines 81 86 eprintln!("You can't pass arguments to interactive mode"); 82 87 exit(1); 83 88 } 84 - args.forwared .push_str(" "); 85 - args.forwared .push_str(&v); 89 + args.forwarded .push_str(" "); 90 + args.forwarded .push_str(&v); 86 91 } 87 92 } 88 93 None => break, skipped 52 lines 141 146 fn test_parse() { 142 147 let args = parse_args(&vec_of_strings!["a", "b", "-c", "-d", "foo", "bar"]); 143 148 assert_eq!(args.script_name, "a".to_string()); 144 - assert_eq!(args.forwared , " b -c -d foo bar".to_string()); 149 + assert_eq!(args.forwarded , " b -c -d foo bar".to_string()); 145 150 } 146 151 147 152 #[test] skipped 1 lines 149 154 let args = parse_args(&vec_of_strings!["-c", ".", "a"]); 150 155 assert_eq!(args.script_name, "a".to_string()); 151 156 assert_eq!(args.change_dir, PathBuf::from(".")); 152 - assert_eq!(args.forwared , "".to_string()); 157 + assert_eq!(args.forwarded , "".to_string()); 153 158 } 154 159 } 155 160