use crate::config::Config;
use anyhow::Result;
use clap::Args as ClapArgs;
#[derive(Debug, ClapArgs)]
pub struct Args {
jail: String,
#[arg(long)]
service: Option<String>,
#[arg(short, long)]
follow: bool,
#[arg(short, long, default_value = "50")]
lines: usize,
#[arg(long)]
timestamps: bool,
}
pub async fn run(args: Args) -> Result<()> {
let config = Config::load().unwrap_or_default();
config.init_logging();
tracing::info!("Viewing logs for jail: {}", args.jail);
tracing::warn!("Log viewing not yet implemented");
Err(anyhow::anyhow!("Log viewing not yet implemented"))
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_logs_args() {
let args = Args {
jail: "rmpca-backend".to_string(),
service: Some("backend".to_string()),
follow: true,
lines: 100,
timestamps: false,
};
assert_eq!(args.jail, "rmpca-backend");
assert_eq!(args.service, Some("backend".to_string()));
assert!(args.follow);
assert_eq!(args.lines, 100);
}
}