mqrs/src/info.rs

25 lines
578 B
Rust
Raw Normal View History

2021-06-14 03:51:26 +02:00
use anyhow::Result;
use clap::Clap;
use posixmq::PosixMq;
/// Print information about an existing message queue
#[derive(Clap, Debug)]
pub struct Info {
/// Name of the queue
2021-06-20 02:00:08 +02:00
#[clap(value_name = "QUEUE")]
2021-06-14 03:51:26 +02:00
pub queue: String,
}
impl Info {
pub fn run(&self) -> Result<()> {
let attrs = PosixMq::open(&self.queue)?.attributes()?;
println!(
"Message queue: {}, msg_max: {}, msgsize_max: {}, current_messages: {}",
&self.queue, &attrs.capacity, &attrs.max_msg_len, &attrs.current_messages
);
Ok(())
}
}