Skip to content

Commit a9eb02b

Browse files
committed
Add file output option
Fixes #5
1 parent 8611bcc commit a9eb02b

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/main.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ mod system_information;
33
use clap::Parser;
44
use local_ip_address::list_afinet_netifas;
55
use std::collections::{HashMap, HashSet};
6+
use std::path::PathBuf;
67
use sysinfo::{Disks, System};
78

89
use crate::system_information::{SystemInformation, SystemNetworkInfo};
@@ -23,6 +24,9 @@ struct Opts {
2324
require_equals = true,
2425
)]
2526
loop_interval: Option<stackable_operator::time::Duration>,
27+
28+
#[clap(long, short = 'o')]
29+
output: Option<PathBuf>,
2630
}
2731

2832
fn main() {
@@ -88,6 +92,9 @@ fn main() {
8892

8993
let serialized = serde_json::to_string_pretty(&system_information).unwrap();
9094
println!("{}", serialized);
95+
if let Some(output_path) = &opts.output {
96+
std::fs::write(output_path, &serialized).unwrap();
97+
}
9198

9299
// TODO:
93100
// Current time

0 commit comments

Comments
 (0)