use anyhow::Result;
use clap::Parser;
use rustdoc_text::{fetch_local_docs, fetch_online_docs};
#[derive(Parser, Debug)]
#[command(author, version, about, long_about = None)]
struct Args {
#[arg(index = 1)]
crate_name: String,
#[arg(index = 2)]
item_path: Option<String>,
#[arg(short, long)]
online: bool,
}
fn main() -> Result<()> {
let args = Args::parse();
let doc_content = if args.online {
fetch_online_docs(&args.crate_name, args.item_path.as_deref())?
} else {
fetch_local_docs(&args.crate_name, args.item_path.as_deref())?
};
println!("{}", doc_content);
Ok(())
}