use clap::{Parser, Subcommand};
#[derive(Subcommand, Debug)]
enum ProvenanceAction {
Migrate {
#[arg(long)]
dry_run: bool,
},
}
#[derive(Parser, Debug)]
#[command(
name = "doiget",
version,
about = "Fetch academic papers via official Open Access APIs.",
long_about = "doiget is an OA-first paper fetcher and stdio MCP server.\n\
See README.md and docs/ for the full specification.\n\
This is the Phase 0 skeleton; subcommands are not yet implemented."
)]
struct Cli {
#[command(subcommand)]
command: Option<Command>,
}
#[derive(Subcommand, Debug)]
enum Command {
Fetch {
ref_: String,
#[arg(long)]
dry_run: bool,
},
Batch {
path: String,
#[arg(long)]
dry_run: bool,
},
Info {
ref_: String,
},
ListRecent {
#[arg(default_value_t = 10)]
limit: usize,
},
Search {
query: String,
},
Bib {
ref_: String,
},
Csl {
ref_: String,
},
AuditLog {
#[arg(long)]
verify: bool,
},
Provenance {
#[command(subcommand)]
action: ProvenanceAction,
},
Serve,
Config {
action: String,
},
#[cfg(feature = "citation")]
Graph {
ref_: String,
#[arg(long)]
depth: Option<u32>,
#[arg(long)]
total: Option<u32>,
#[arg(long)]
per_paper: Option<u32>,
},
}
#[tokio::main]
async fn main() -> anyhow::Result<()> {
tracing_subscriber::fmt()
.with_writer(std::io::stderr)
.with_env_filter(tracing_subscriber::EnvFilter::from_default_env())
.init();
let cli = Cli::parse();
match cli.command {
None => {
anyhow::bail!("no subcommand. Run `doiget --help` for available commands.");
}
Some(Command::AuditLog { verify }) => doiget_cli::commands::audit_log::run(verify),
Some(Command::Provenance { action }) => match action {
ProvenanceAction::Migrate { dry_run } => {
doiget_cli::commands::provenance::migrate(dry_run)
}
},
Some(Command::Config { action }) => doiget_cli::commands::config::run(action),
Some(Command::Info { ref_ }) => doiget_cli::commands::info::run(ref_),
Some(Command::ListRecent { limit }) => doiget_cli::commands::list_recent::run(limit),
Some(Command::Search { query }) => doiget_cli::commands::search::run(query),
Some(Command::Fetch { ref_, dry_run }) => {
doiget_cli::commands::fetch::run_with_options(ref_, dry_run).await
}
Some(Command::Batch { path, dry_run }) => {
doiget_cli::commands::batch::run_with_options(path, dry_run).await
}
Some(Command::Bib { ref_ }) => doiget_cli::commands::bib::run(ref_),
Some(Command::Csl { ref_ }) => doiget_cli::commands::csl::run(ref_),
Some(Command::Serve) => {
let profile = doiget_core::CapabilityProfile::from_env()?;
doiget_mcp::Server::new(profile).run().await
}
#[cfg(feature = "citation")]
Some(Command::Graph {
ref_,
depth,
total,
per_paper,
}) => doiget_cli::commands::graph::run(ref_, depth, total, per_paper).await,
}
}