use anyhow::Result;
use ghactions::ToolCache;
#[tokio::main]
async fn main() -> Result<()> {
println!("Tool Cache Example:\n");
let tool_cache = ToolCache::from("./examples/toolcache");
let path = tool_cache
.find("node", "12.7.0")
.await
.expect("Failed to find tool in cache");
println!("Node (exact) :: {}", path);
let path = tool_cache
.find("node", "12.x")
.await
.expect("Failed to find tool in cache");
println!("Node (fuzzy version) :: {}", path);
let path = tool_cache
.find_with_arch("node", "12.7.0", "x64")
.await
.expect("Failed to find tool in cache");
println!("Node (exact, x64) :: {}", path);
let versions = tool_cache
.find_all_version("node")
.await
.expect("Failed to find all versions of tool in cache");
println!("\nNode Versions ::");
versions.iter().for_each(|v| println!("- Node :: {}", v));
let node = tool_cache.find("node", "12.7.0").await?.join("node");
println!("\nNode Path :: {:?}", node);
match tool_cache.find("non-existent-tool", "1.0.0").await {
Ok(path) => {
panic!("Found non-existent tool :: {:?}", path);
}
Err(e) => {
println!("\nNon-existent tool :: {:?}", e);
}
};
Ok(())
}