Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions src/command/handler/uds_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ pub async fn handle(matches: ArgMatches, socket: UnixDatagram) -> HandleUdsResul
ActionType::Create => handle_create(socket, sub_matches).await?,
ActionType::Queue => handle_queue(socket, sub_matches).await?,
ActionType::Delete => handle_delete(socket, sub_matches).await?,
ActionType::List => handle_list(socket).await?,
ActionType::List => handle_list(socket, sub_matches).await?,
ActionType::Test => handle_test(socket).await?,
ActionType::History => handle_history(socket).await?,
ActionType::Exit | ActionType::Clear => {
Expand Down Expand Up @@ -108,10 +108,12 @@ async fn handle_delete(socket: UnixDatagram, sub_matches: &ArgMatches) -> Handle
Ok(())
}

async fn handle_list(socket: UnixDatagram) -> HandleUdsResult {
async fn handle_list(socket: UnixDatagram, sub_matches: &ArgMatches) -> HandleUdsResult {
let show_percentage = sub_matches.get_flag("percentage");

socket
.send(
UdsMessage::Public(MessageRequest::List)
UdsMessage::Public(MessageRequest::List { show_percentage })
.encode()
.map_err(UdsHandlerError::EncodeFailed)?
.as_slice(),
Expand Down
10 changes: 8 additions & 2 deletions src/ipc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ pub enum MessageRequest {
Create { work: u16, r#break: u16 },
Queue { work: u16, r#break: u16 },
Delete { id: u16, all: bool },
List,
List { show_percentage: bool },
Test,
History,
}
Expand Down Expand Up @@ -97,7 +97,13 @@ impl From<MessageRequest> for UserInput {
format!("{} -i {}", String::from(ActionType::Delete), id)
}
}
MessageRequest::List => String::from(ActionType::List),
MessageRequest::List { show_percentage } => {
if show_percentage {
format!("{} -p", String::from(ActionType::List))
} else {
String::from(ActionType::List)
}
}
MessageRequest::Test => String::from(ActionType::Test),
MessageRequest::History => String::from(ActionType::History),
};
Expand Down