32 lines
679 B
Rust
32 lines
679 B
Rust
use anyhow::Result;
|
|
use clap::Parser;
|
|
use log::info;
|
|
use sysvmq::SysvMq;
|
|
|
|
/// Create a SysV message queue
|
|
#[derive(Debug, Parser)]
|
|
pub struct Create {
|
|
/// Permissions (octal) to create the queue with (default: 0644)
|
|
#[clap(short, long)]
|
|
mode: Option<String>,
|
|
/// Key of the new queue
|
|
#[clap(value_name = "KEY")]
|
|
key: i32,
|
|
}
|
|
|
|
impl Create {
|
|
pub fn run(&self) -> Result<()> {
|
|
let mut mq = SysvMq::<String>::new();
|
|
|
|
if let Some(m) = &self.mode {
|
|
mq.mode(i32::from_str_radix(&m, 8)?);
|
|
}
|
|
|
|
mq.create(self.key)?;
|
|
|
|
info!("SysV message queue created, key: {}, id: {}", mq.key, mq.id);
|
|
|
|
Ok(())
|
|
}
|
|
}
|