use super::args::{Commands, MessageCommand};
use crate::{GenericQueueManager, QueueID};
extern crate alloc;
impl Commands {
#[inline]
pub async fn execute(
self,
queue_manager: alloc::sync::Arc<impl GenericQueueManager + Send + Sync>,
) -> anyhow::Result<()> {
match self {
Self::Show {
queues,
empty_token,
} => {
Self::show(
if queues.is_empty() {
<QueueID as strum::IntoEnumIterator>::iter().collect::<Vec<_>>()
} else {
queues
},
queue_manager,
empty_token,
&mut std::io::stdout(),
)
.await
}
Self::Msg { msg, command } => match command {
MessageCommand::Show { format } => {
Self::message_show(&msg, &queue_manager, &format, &mut std::io::stdout()).await
}
MessageCommand::Move { queue } => {
Self::message_move(&msg, &queue, queue_manager).await
}
MessageCommand::Remove { yes } => {
Self::message_remove(
&msg,
yes,
queue_manager,
&mut std::io::stdout(),
tokio::io::stdin(),
)
.await
}
#[allow(clippy::unimplemented)]
MessageCommand::ReRun {} => unimplemented!(),
},
}
}
}