修改表情

main
阳光少年 1 year ago
parent 6a58be124f
commit e8b688deed

@ -38,6 +38,9 @@ static LOGO: &str = r#"
\ \_\ \_\ \____/\ \____\\ \_\ \_\ \____\\ \_\ \ \_\ \_\ \____/\ \____\\ \_\ \_\ \____\\ \_\
\/_/\/ /\/___/ \/____/ \/_/\/_/\/____/ \/_/ \/_/\/ /\/___/ \/____/ \/_/\/_/\/____/ \/_/
"#; "#;
static Y: &str = "🟢";
static N: &str = "🔴";
#[derive(Parser, Debug)] #[derive(Parser, Debug)]
#[command(version, about, long_about = None)] #[command(version, about, long_about = None)]
@ -448,7 +451,7 @@ fn run_container(container_info: &ContainerInfo, is_exec_cmd: Option<&String>) -
let err = process::Command::new(cmd_vec[0]) let err = process::Command::new(cmd_vec[0])
.args(&cmd_vec[1..]) .args(&cmd_vec[1..])
.exec(); .exec();
println!("🔴 execv {cmd_vec:?}失败: {err:?}"); println!("{N} execv {cmd_vec:?}失败: {err:?}");
0isize 0isize
}; };
clone_flags = CloneFlags::empty(); clone_flags = CloneFlags::empty();
@ -503,7 +506,7 @@ fn run_container(container_info: &ContainerInfo, is_exec_cmd: Option<&String>) -
let err = process::Command::new(cmd_vec[0]) let err = process::Command::new(cmd_vec[0])
.args(&cmd_vec[1..]) .args(&cmd_vec[1..])
.exec(); .exec();
println!("🔴 execv {cmd_vec:?}失败: {err:?}"); println!("{N} execv {cmd_vec:?}失败: {err:?}");
0isize 0isize
}; };
clone_flags = CloneFlags::from_bits_truncate(CLONE_FLAG); clone_flags = CloneFlags::from_bits_truncate(CLONE_FLAG);
@ -524,8 +527,8 @@ impl Display for ContainerStatus {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self { match self {
Self::READY => write!(f, "😀"), Self::READY => write!(f, "😀"),
Self::RUNNING => write!(f, "🟢"), Self::RUNNING => write!(f, "{Y}"),
Self::STOP => write!(f, "🔴"), Self::STOP => write!(f, "{N}"),
} }
} }
} }
@ -663,8 +666,8 @@ fn stop_container(containers_id: &str, is_remove: bool) -> Result<()> {
// 删除容器目录 // 删除容器目录
if is_remove { if is_remove {
match fs::remove_dir_all(container_work_path) { match fs::remove_dir_all(container_work_path) {
Ok(_) => println!("🟢 删除容器 {container_id} 成功"), Ok(_) => println!("{Y} 删除容器 {container_id} 成功"),
Err(e) => println!("🔴 删除容器失败: {e:?}"), Err(e) => println!("{N} 删除容器失败: {e:?}"),
} }
} }
} else { } else {
@ -718,16 +721,16 @@ fn main() -> Result<()>{
match run_container(&container_info, None) { match run_container(&container_info, None) {
Ok(_) => { Ok(_) => {
if container_info.wait { if container_info.wait {
println!("🟢 容器 {} 运行完毕", container_info.id); println!("{Y} 容器 {} 运行完毕", container_info.id);
remove_network(&container_info.id); remove_network(&container_info.id);
} else { } else {
println!("🟢 主进程退出"); println!("{Y} 主进程退出");
} }
} }
Err(e) => { Err(e) => {
// clone 之后的错误 这里已经无法捕获了 // clone 之后的错误 这里已经无法捕获了
// clone 之前出错, 清理工作目录 // clone 之前出错, 清理工作目录
println!("🔴 run_container失败: {e}"); println!("{N} run_container失败: {e}");
let is_remove = args.restart.is_none(); let is_remove = args.restart.is_none();
stop_container(&container_info.id, is_remove)?; stop_container(&container_info.id, is_remove)?;
} }

Loading…
Cancel
Save