Add a libraries command and scan subcommand

This commit is contained in:
Marc Plano-Lesay 2024-11-17 15:31:12 +01:00
parent 2eb4e391c2
commit af1af8dce1
Signed by: kernald
GPG key ID: 66A41B08CC62A6CF
9 changed files with 182 additions and 1 deletions

View file

@ -0,0 +1,31 @@
use color_eyre::eyre::Result;
use crate::{context::Context, models::library::Library};
use super::action::Action;
pub struct FetchAllLibraries {}
impl Action for FetchAllLibraries {
type Input = ();
type Output = Vec<Library>;
fn new(_input: Self::Input) -> Self {
Self {}
}
fn describe(&self) -> String {
String::from("Fetching all libraries")
}
async fn execute(&self, ctx: &Context) -> Result<Self::Output> {
Ok(ctx
.client
.get_all_libraries()
.await?
.clone()
.into_iter()
.map(Into::into)
.collect())
}
}