| 8 | use crate::steps::workspace; |
| 9 | |
| 10 | pub fn vscode(arg: Option<String>, y: bool) -> Result<String> { |
| 11 | if let Some(origin) = arg { |
| 12 | match vscode::verify(&origin) { |
| 13 | Err(e) => Err(anyhow!("VS Code 验证失败:{}", e)), |
| 14 | Ok(_) => Ok(origin), |
| 15 | } |
| 16 | } else { |
| 17 | let scanned = vscode::scan(); |
| 18 | if y { |
| 19 | match scanned { |
| 20 | Some(v) => Ok(v), |
| 21 | None => Err(anyhow!("未找到已安装的 VS Code")), |
| 22 | } |
| 23 | } else { |
| 24 | let mut builder = Question::input("vscode") |
| 25 | .message("VS Code 路径:") |
| 26 | .validate_on_key(|s, _| vscode::verify(s).is_ok()) |
| 27 | .validate(|s, _| vscode::verify(s).map_err(|s| format!("验证失败:{}", s))); |
| 28 | if let Some(dft) = vscode::scan() { |
| 29 | builder = builder.default(dft); |
| 30 | } |
| 31 | Ok(prompt_one(builder.build())?.as_string().unwrap().into()) |
| 32 | } |
| 33 | } |
| 34 | } |
| 35 | |
| 36 | pub fn setup(arg: Option<&'static CompilerSetup>, y: bool) -> Result<&'static CompilerSetup> { |
| 37 | if y { |