#[macro_use] extern crate miette; #[macro_use] extern crate serde; mod install; use std::path::{Path, PathBuf}; use miette::{IntoDiagnostic, Result, WrapErr}; use install::{Pipeline, RemoteResource, Step}; const SWTOOLS_PATH: &'static str = "C:\\SWTools"; pub fn swtools_path() -> &'static Path { Path::new(SWTOOLS_PATH) } pub struct Context { pub reqwest: reqwest::Client, } #[tokio::main(flavor = "current_thread")] async fn main() -> Result<()> { println!("Bootstrapping..."); if cfg!(not(windows)) { bail!("Your platform is not supported."); } if !swtools_path().exists() { bail!("Could not find or access {}", SWTOOLS_PATH); } let utilities = [Pipeline::new( "Install Notepad++", vec![ Step::DownloadFile { file: swtools_path() .join("temp") .join("notepad-plus-plus.zip") .into(), res: RemoteResource::GitHubArtifact { repo: "notepad-plus-plus/notepad-plus-plus", pattern: "npp.{{tag_name_strip_prefix}}.portable.x64.zip", }, }, ], )]; let ctx = Context { reqwest: reqwest::Client::builder().build().into_diagnostic().wrap_err("Could not initialize HTTP client.")?, }; for utility in utilities { utility.invoke(&ctx).await?; } Ok(()) }