Args clone

This commit is contained in:
2024-12-21 20:59:49 +00:00
parent 04782f4a11
commit af4eb6c34f

View File

@@ -2,7 +2,7 @@ use clap::Parser;
use std::thread::sleep; use std::thread::sleep;
use std::time::Duration; use std::time::Duration;
#[derive(Parser, Debug)] #[derive(Parser, Debug, Clone)]
#[command(version, about, long_about = None)] #[command(version, about, long_about = None)]
struct Args { struct Args {
/// Run in foreground /// Run in foreground
@@ -34,12 +34,12 @@ struct Args {
interfaces: Vec<String>, interfaces: Vec<String>,
} }
struct Monitor<'a> { struct Monitor{
args: &'a Args, args: Args,
} }
impl<'a> Monitor<'a> { impl Monitor {
fn new(args: &'a Args) -> Self { fn new(args: Args) -> Self {
Self { args } Self { args }
} }
@@ -62,7 +62,8 @@ impl<'a> Monitor<'a> {
fn main() { fn main() {
let args = Args::parse(); let args = Args::parse();
let mut monitor = Monitor::new(&args); // let mut monitor = Monitor::new(&args);
let mut monitor = Monitor::new(args.clone());
if args.interfaces.is_empty() { if args.interfaces.is_empty() {
eprintln!("No interfaces to monitor"); eprintln!("No interfaces to monitor");