diff --git a/rocks-bin/src/download.rs b/rocks-bin/src/download.rs new file mode 100644 index 00000000..54879d9a --- /dev/null +++ b/rocks-bin/src/download.rs @@ -0,0 +1,14 @@ +use anyhow::Result; +use clap::Args; + +#[derive(Args)] +pub struct Download { + name: String, + version: String, +} + +pub async fn download(dl_data: Download) -> Result<()> { + rocks_lib::rocks::download(&dl_data.name, Some(&dl_data.version)).await?; + + Ok(()) +} diff --git a/rocks-bin/src/main.rs b/rocks-bin/src/main.rs index 7e2b1cd6..96f309a5 100644 --- a/rocks-bin/src/main.rs +++ b/rocks-bin/src/main.rs @@ -2,6 +2,7 @@ use std::path::PathBuf; use clap::{Parser, Subcommand}; +mod download; mod search; /// An small and efficient Lua package manager. @@ -80,7 +81,7 @@ enum Commands { /// Show documentation for an installed rock. Doc, /// Download a specific rock file from a rocks server. - Download, + Download(download::Download), /// Initialize a directory for a Lua project using Rocks. Init, /// Install a rock. @@ -124,6 +125,7 @@ async fn main() { match cli.command { Some(command) => match command { Commands::Search(search_data) => search::search(search_data).await.unwrap(), + Commands::Download(download_data) => download::download(download_data).await.unwrap(), _ => unimplemented!(), }, None => {