2024-07-22 20:51:46 +00:00
|
|
|
use std::{env, fs};
|
|
|
|
|
|
|
|
use anyhow::{anyhow, Result};
|
|
|
|
use crate::bencode::Bencode;
|
|
|
|
|
2024-07-21 10:46:10 +00:00
|
|
|
mod bencode;
|
|
|
|
|
2024-07-22 20:51:46 +00:00
|
|
|
fn main() -> Result<()> {
|
|
|
|
let args: Vec<String> = env::args().collect();
|
|
|
|
if args.len() < 2 {
|
|
|
|
return Err(anyhow!("Please specify the torrent file to download"));
|
|
|
|
}
|
|
|
|
let file_path = &args[1];
|
|
|
|
|
|
|
|
let torrent_bytes = fs::read(&file_path)?;
|
|
|
|
|
|
|
|
let _torrent_decoded = Bencode::decode(&torrent_bytes)?;
|
|
|
|
|
|
|
|
println!("torrent decoded: {_torrent_decoded}");
|
|
|
|
|
|
|
|
Ok(())
|
2024-07-21 10:46:10 +00:00
|
|
|
}
|