mirror of
https://github.com/edera-dev/krata.git
synced 2025-08-10 00:21:31 +00:00
kratactl: rework to separate commands
This commit is contained in:
26
crates/kratactl/src/cli/pretty.rs
Normal file
26
crates/kratactl/src/cli/pretty.rs
Normal file
@ -0,0 +1,26 @@
|
||||
use krata::common::{GuestState, GuestStatus};
|
||||
|
||||
pub fn guest_status_text(status: GuestStatus) -> String {
|
||||
match status {
|
||||
GuestStatus::Destroy => "destroying",
|
||||
GuestStatus::Destroyed => "destroyed",
|
||||
GuestStatus::Start => "starting",
|
||||
GuestStatus::Exited => "exited",
|
||||
GuestStatus::Started => "started",
|
||||
_ => "unknown",
|
||||
}
|
||||
.to_string()
|
||||
}
|
||||
|
||||
pub fn guest_state_text(state: GuestState) -> String {
|
||||
let mut text = guest_status_text(state.status());
|
||||
|
||||
if let Some(exit) = state.exit_info {
|
||||
text.push_str(&format!(" (exit code: {})", exit.code));
|
||||
}
|
||||
|
||||
if let Some(error) = state.error_info {
|
||||
text.push_str(&format!(" (error: {})", error.message));
|
||||
}
|
||||
text
|
||||
}
|
Reference in New Issue
Block a user