Add a libraries command and scan subcommand
This commit is contained in:
parent
2eb4e391c2
commit
af1af8dce1
9 changed files with 182 additions and 1 deletions
31
src/actions/fetch_all_libraries.rs
Normal file
31
src/actions/fetch_all_libraries.rs
Normal 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())
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue