mod read;
mod register;
use super::CommandError;
use clap::Subcommand;
use knowledge_base_crud::KnowledgeBaseRepository;
use knowledge_base_models::ReferenceId;
use std::process::ExitCode;
#[derive(Debug, Subcommand)]
pub enum Command {
Read { id: ReferenceId },
Register {
#[arg(long)]
url: String,
#[arg(long)]
title: String,
#[arg(long)]
publisher: Option<String>,
#[arg(long)]
publication_date: Option<String>,
#[arg(long)]
source_language: Option<String>,
#[arg(long)]
archive_url: Option<String>,
#[arg(long)]
dry_run: bool,
},
}
pub fn execute(command: Command, knowledge_base: &KnowledgeBaseRepository) -> Result<ExitCode, CommandError> {
match command {
Command::Read { id } => read::execute(knowledge_base, &id),
Command::Register {
url,
title,
publisher,
publication_date,
source_language,
archive_url,
dry_run,
} => register::execute(
knowledge_base,
register::Args {
url,
title,
publisher,
publication_date,
source_language,
archive_url,
dry_run,
},
),
}
}