use crate::api;
use crate::cli::client::KrillClient;
use crate::cli::report::Report;
use crate::commons::httpclient;
#[derive(clap::Subcommand)]
pub enum Command {
Refresh(Refresh),
Publish(Publish),
Sync(SyncRepo),
}
impl Command {
pub async fn run(self, client: &KrillClient) -> Report {
match self {
Self::Refresh(cmd) => cmd.run(client).await.into(),
Self::Publish(cmd) => cmd.run(client).await.into(),
Self::Sync(cmd) => cmd.run(client).await.into(),
}
}
}
#[derive(clap::Parser)]
pub struct Refresh;
impl Refresh {
pub async fn run(
self, client: &KrillClient
) -> Result<api::status::Success, httpclient::Error> {
client.bulk_sync_parents().await
}
}
#[derive(clap::Parser)]
pub struct Publish;
impl Publish {
pub async fn run(
self, client: &KrillClient
) -> Result<api::status::Success, httpclient::Error> {
client.bulk_publish().await
}
}
#[derive(clap::Parser)]
pub struct SyncRepo;
impl SyncRepo {
pub async fn run(
self, client: &KrillClient
) -> Result<api::status::Success, httpclient::Error> {
client.bulk_sync_repo().await
}
}