Remove a message queue
This commit is contained in:
parent
fdacba1eec
commit
fe877b230c
3 changed files with 26 additions and 1 deletions
|
@ -1,4 +1,4 @@
|
||||||
use crate::create::Create;
|
use crate::{create::Create, unlink::Unlink};
|
||||||
use clap::{crate_authors, crate_version, AppSettings, Clap};
|
use clap::{crate_authors, crate_version, AppSettings, Clap};
|
||||||
|
|
||||||
#[derive(Clap, Debug)]
|
#[derive(Clap, Debug)]
|
||||||
|
@ -20,4 +20,5 @@ pub struct Opts {
|
||||||
#[derive(Clap, Debug)]
|
#[derive(Clap, Debug)]
|
||||||
pub enum Command {
|
pub enum Command {
|
||||||
Create(Create),
|
Create(Create),
|
||||||
|
Unlink(Unlink),
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,6 +3,7 @@ use clap::Clap;
|
||||||
|
|
||||||
mod cli;
|
mod cli;
|
||||||
mod create;
|
mod create;
|
||||||
|
mod unlink;
|
||||||
|
|
||||||
use cli::{Command, Opts};
|
use cli::{Command, Opts};
|
||||||
|
|
||||||
|
@ -11,6 +12,7 @@ fn main() -> Result<()> {
|
||||||
|
|
||||||
match opts.command {
|
match opts.command {
|
||||||
Command::Create(c) => c.run(opts.verbose)?,
|
Command::Create(c) => c.run(opts.verbose)?,
|
||||||
|
Command::Unlink(u) => u.run(opts.verbose)?,
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|
22
src/unlink.rs
Normal file
22
src/unlink.rs
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
use anyhow::Result;
|
||||||
|
use clap::Clap;
|
||||||
|
|
||||||
|
/// Delete a message queue
|
||||||
|
#[derive(Clap, Debug)]
|
||||||
|
pub struct Unlink {
|
||||||
|
/// Name of the queue
|
||||||
|
#[clap(value_name = "QNAME")]
|
||||||
|
pub queue: String,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Unlink {
|
||||||
|
pub fn run(&self, verbose: bool) -> Result<()> {
|
||||||
|
posixmq::remove_queue(&self.queue)?;
|
||||||
|
|
||||||
|
if verbose {
|
||||||
|
println!("Removed message queue: {}", &self.queue);
|
||||||
|
}
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue