quickpeep/quickpeep_raker/src/bin/qp-seeds.rs

46 lines
1.1 KiB
Rust

use clap::Parser;
use env_logger::Env;
use anyhow::{bail, Context};
use std::path::PathBuf;
use quickpeep_raker::config;
/// Seeds a raker's queue with URLs
#[derive(Clone, Debug, Parser)]
pub struct Opts {
#[clap(long = "config")]
config: Option<PathBuf>,
#[clap(long = "import")]
/// Import the seeds into the workbench
import: bool,
}
#[tokio::main]
pub async fn main() -> anyhow::Result<()> {
env_logger::Builder::from_env(Env::default().default_filter_or("info,quickpeep=debug")).init();
let opts: Opts = Opts::parse();
let config_path = opts
.config
.unwrap_or_else(|| PathBuf::from("qp_raker.toml"));
let config = config::RakerConfig::load(&config_path).context("Failed to load config")?;
if !config.workbench_dir.exists() {
bail!(
"Workbench directory ({:?}) doesn't exist.",
config.workbench_dir
);
}
if !config.seed_dir.exists() {
bail!("Seed directory ({:?}) doesn't exist.", config.seed_dir);
}
eprintln!("{:#?}", config);
Ok(())
}