rename argument mod to config; implement name, tracker config options

This commit is contained in:
yggverse 2025-09-08 15:11:52 +03:00
parent bdc5496d45
commit e8b409c4d6
2 changed files with 39 additions and 14 deletions

41
src/config.rs Normal file
View file

@ -0,0 +1,41 @@
use clap::Parser;
use std::{
net::{Ipv4Addr, SocketAddr, SocketAddrV4},
path::PathBuf,
};
#[derive(Parser, Debug)]
#[command(version, about, long_about = None)]
pub struct Config {
/// Server name
#[arg(short, long, default_value_t = String::from("βtracker"))]
pub name: String,
/// Tracker(s) to join / scrape requests
#[arg(short, long)]
pub tracker: Option<Vec<String>>,
/// Bind server `host:port` to listen incoming connections on it
#[arg(short, long, default_value_t = SocketAddr::V4(SocketAddrV4::new(Ipv4Addr::LOCALHOST, 1965)))]
pub bind: SocketAddr,
/// Filepath to server identity in PKCS (PFX) format
#[arg(short, long)]
pub identity: PathBuf,
/// Passphrase to unlock encrypted identity
#[arg(short, long, default_value_t = String::new())]
pub password: String,
/// btracker-fs directory
#[arg(short, long)]
pub storage: PathBuf,
/// Listing items limit
#[arg(short, long, default_value_t = 10)]
pub limit: usize,
/// Default index capacity
#[arg(short, long, default_value_t = 1000)]
pub capacity: usize,
}