From f40ddb06bfbcac6453c31d49a6448c0e57613b61 Mon Sep 17 00:00:00 2001 From: karminski Date: Wed, 25 Oct 2023 16:16:12 +0800 Subject: [PATCH] ADD more info for docker does not instanned case. --- src/command/deploy.rs | 7 +++++-- src/command/doctor.rs | 21 ++++++++++++++------- src/command/remove.rs | 7 +++++-- src/command/restart.rs | 7 +++++-- src/command/stop.rs | 7 +++++-- src/command/update.rs | 7 +++++-- 6 files changed, 39 insertions(+), 17 deletions(-) diff --git a/src/command/deploy.rs b/src/command/deploy.rs index 863677b..1f92575 100644 --- a/src/command/deploy.rs +++ b/src/command/deploy.rs @@ -86,11 +86,14 @@ async fn deploy_self_host( let _docker = Docker::connect_with_local_defaults().unwrap(); if (_docker.ping().await).is_err() { println!( - "{} {}\n{} {}", + "{} {}\n{} {}\n\n{}\n\n{}\n\n{}\n", ui::emoji::FAIL, String::from("No running docker found."), ui::emoji::WARN, - style("Please check the status of docker.").red(), + style("Please check the status of docker with command: docker info").red(), + String::from("If you do not have Docker installed, please refer to the following content for instructions on how to install it: "), + style("https://docs.docker.com/engine/install/").blue(), + String::from("Once Docker is installed, please try running the command again."), ); process::exit(1); } diff --git a/src/command/doctor.rs b/src/command/doctor.rs index 6955bc0..f519916 100644 --- a/src/command/doctor.rs +++ b/src/command/doctor.rs @@ -35,6 +35,19 @@ impl Cmd { let new_spinner_style = ProgressStyle::with_template("{wide_msg}").unwrap(); pb.set_style(new_spinner_style); let _docker = Docker::connect_with_local_defaults().unwrap(); + let error_info = |pb: ProgressBar| { + pb.println(format!( + "{} {}\n{} {}\n\n{}\n\n{}\n\n{}\n", + ui::emoji::FAIL, + String::from("No running docker found."), + ui::emoji::WARN, + style("Please check the status of docker with command: docker info").red(), + String::from("If you do not have Docker installed, please refer to the following content for instructions on how to install it: "), + style("https://docs.docker.com/engine/install/").blue(), + String::from("Once Docker is installed, please try running the command again."), + )); + pb.finish_with_message(format!("illa doctor exited.")); + }; match _docker.version().await { Ok(version) => pb.finish_with_message(format!( "{} {}: {}\n{} {}", @@ -44,13 +57,7 @@ impl Cmd { ui::emoji::SPARKLE, style("Success! The minimum requirement for deploying ILLA has been satisfied. Self-Host your ILLA Builder by command [illa deploy].").green(), )), - Err(e) => pb.finish_with_message(format!( - "{} {}\n{} {}", - ui::emoji::FAIL, - String::from("No running docker found."), - ui::emoji::WARN, - style("Please check the status of docker.").red(), - )) + Err(e) => error_info(pb), } println!(); Ok(()) diff --git a/src/command/remove.rs b/src/command/remove.rs index 8457893..c269249 100644 --- a/src/command/remove.rs +++ b/src/command/remove.rs @@ -51,11 +51,14 @@ async fn remove_local(is_force: bool, data: bool) -> Result { let _docker = Docker::connect_with_local_defaults().unwrap(); if (_docker.ping().await).is_err() { println!( - "{} {}\n{} {}", + "{} {}\n{} {}\n\n{}\n\n{}\n\n{}\n", ui::emoji::FAIL, String::from("No running docker found."), ui::emoji::WARN, - style("Please check the status of docker.").red(), + style("Please check the status of docker with command: docker info").red(), + String::from("If you do not have Docker installed, please refer to the following content for instructions on how to install it: "), + style("https://docs.docker.com/engine/install/").blue(), + String::from("Once Docker is installed, please try running the command again."), ); process::exit(1); } diff --git a/src/command/restart.rs b/src/command/restart.rs index 0b85013..5072a12 100644 --- a/src/command/restart.rs +++ b/src/command/restart.rs @@ -42,11 +42,14 @@ async fn restart_local() -> Result { let _docker = Docker::connect_with_local_defaults().unwrap(); if (_docker.ping().await).is_err() { println!( - "{} {}\n{} {}", + "{} {}\n{} {}\n\n{}\n\n{}\n\n{}\n", ui::emoji::FAIL, String::from("No running docker found."), ui::emoji::WARN, - style("Please check the status of docker.").red(), + style("Please check the status of docker with command: docker info").red(), + String::from("If you do not have Docker installed, please refer to the following content for instructions on how to install it: "), + style("https://docs.docker.com/engine/install/").blue(), + String::from("Once Docker is installed, please try running the command again."), ); process::exit(1); } diff --git a/src/command/stop.rs b/src/command/stop.rs index e2f2ee8..9578d8c 100644 --- a/src/command/stop.rs +++ b/src/command/stop.rs @@ -42,11 +42,14 @@ async fn stop_local() -> Result { let _docker = Docker::connect_with_local_defaults().unwrap(); if (_docker.ping().await).is_err() { println!( - "{} {}\n{} {}", + "{} {}\n{} {}\n\n{}\n\n{}\n\n{}\n", ui::emoji::FAIL, String::from("No running docker found."), ui::emoji::WARN, - style("Please check the status of docker.").red(), + style("Please check the status of docker with command: docker info").red(), + String::from("If you do not have Docker installed, please refer to the following content for instructions on how to install it: "), + style("https://docs.docker.com/engine/install/").blue(), + String::from("Once Docker is installed, please try running the command again."), ); process::exit(1); } diff --git a/src/command/update.rs b/src/command/update.rs index 7ba2498..b7fd2c2 100644 --- a/src/command/update.rs +++ b/src/command/update.rs @@ -63,11 +63,14 @@ async fn update_local(progress_style: ProgressStyle) -> Result { let _docker = Docker::connect_with_local_defaults().unwrap(); if (_docker.ping().await).is_err() { println!( - "{} {}\n{} {}", + "{} {}\n{} {}\n\n{}\n\n{}\n\n{}\n", ui::emoji::FAIL, String::from("No running docker found."), ui::emoji::WARN, - style("Please check the status of docker.").red(), + style("Please check the status of docker with command: docker info").red(), + String::from("If you do not have Docker installed, please refer to the following content for instructions on how to install it: "), + style("https://docs.docker.com/engine/install/").blue(), + String::from("Once Docker is installed, please try running the command again."), ); process::exit(1); }