torrent-rs/src/main.rs

23 lines
486 B
Rust
Raw Normal View History

use std::{env, fs};
use anyhow::{anyhow, Result};
use crate::bencode::Bencode;
2024-07-21 10:46:10 +00:00
mod bencode;
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
}