| 34 | } |
| 35 | |
| 36 | pub fn setup(arg: Option<&'static CompilerSetup>, y: bool) -> Result<&'static CompilerSetup> { |
| 37 | if y { |
| 38 | match arg { |
| 39 | Some(v) => Ok(v), |
| 40 | None => { |
| 41 | info!("未传入 -s,默认使用 {} 类型编译器", ENABLED_SETUPS[0].id); |
| 42 | Ok(ENABLED_SETUPS[0]) |
| 43 | } |
| 44 | } |
| 45 | } else { |
| 46 | let q = Question::select("setup") |
| 47 | .message("编译器类型:") |
| 48 | .choices( |
| 49 | ENABLED_SETUPS |
| 50 | .iter() |
| 51 | .map(|s| format!("{} \x1b[38;5;242m({})\x1b[0m", s.name, s.description)), |
| 52 | ) |
| 53 | .build(); |
| 54 | let i = prompt_one(q)?.as_list_item().unwrap().index; |
| 55 | Ok(ENABLED_SETUPS[i]) |
| 56 | } |
| 57 | } |
| 58 | |
| 59 | pub fn compiler(setup: &'static CompilerSetup, arg: Option<String>, y: bool) -> Result<Compiler> { |
| 60 | if let Some(path) = arg { |