mirror of
https://github.com/crunchy-labs/crunchy-cli.git
synced 2026-01-21 04:02:00 -06:00
Add pre_check checking
This commit is contained in:
parent
c383b4d307
commit
933d217b63
1 changed files with 16 additions and 6 deletions
|
|
@ -152,18 +152,28 @@ pub async fn cli_entrypoint() {
|
|||
.unwrap();
|
||||
debug!("Created ctrl-c handler");
|
||||
|
||||
let result = match cli.command {
|
||||
Command::Archive(archive) => archive.execute(ctx).await,
|
||||
Command::Download(download) => download.execute(ctx).await,
|
||||
match cli.command {
|
||||
Command::Archive(archive) => execute_executor(archive,ctx).await,
|
||||
Command::Download(download) => execute_executor(download, ctx).await,
|
||||
Command::Login(login) => {
|
||||
if login.remove {
|
||||
Ok(())
|
||||
return;
|
||||
} else {
|
||||
login.execute(ctx).await
|
||||
execute_executor(login, ctx).await
|
||||
}
|
||||
}
|
||||
};
|
||||
if let Err(err) = result {
|
||||
}
|
||||
|
||||
/// Cannot be done in the main function. I wanted to return `dyn` [`Execute`] from the match but had to
|
||||
/// box it which then conflicts with [`Execute::execute`] which consumes `self`
|
||||
async fn execute_executor(executor: impl Execute, ctx: Context) {
|
||||
if let Err(err) = executor.pre_check() {
|
||||
error!("Misconfigurations detected: {}", err);
|
||||
std::process::exit(1)
|
||||
}
|
||||
|
||||
if let Err(err) = executor.execute(ctx).await {
|
||||
error!("a unexpected error occurred: {}", err);
|
||||
std::process::exit(1)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue