Skip to content

Commit

Permalink
feat(bin): add download command
Browse files Browse the repository at this point in the history
  • Loading branch information
vhyrro committed Jan 18, 2024
1 parent d974080 commit 68f3b15
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
14 changes: 14 additions & 0 deletions rocks-bin/src/download.rs
Original file line number Diff line number Diff line change
@@ -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(())
}
4 changes: 3 additions & 1 deletion rocks-bin/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ use std::path::PathBuf;

use clap::{Parser, Subcommand};

mod download;
mod search;

/// An small and efficient Lua package manager.
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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 => {
Expand Down

0 comments on commit 68f3b15

Please sign in to comment.