exit on error, added support to detect if engine avaible

This commit is contained in:
Shihaam Abdul Rahman 2023-10-06 00:43:12 +05:00
parent 3f391f2392
commit 9fc61e0561
Signed by: shihaam
GPG Key ID: 6DA2E87EBC227636

View File

@ -1,8 +1,8 @@
#!/bin/bash
check_file() {
local file=""
local engine=""
file=""
engine=""
local opt
local OPTARG
local OPTIND=1
@ -54,11 +54,11 @@ check_file() {
file="container-compose.yml"
else
echo "no compose.yaml, compose.yml, docker-compose.yaml, docker-compose.yml, podman-compose.yml, podman-compose.yaml, container-compose.yaml or container-compose.yml file found, pass files with -f"
return 1
exit 1
fi
elif [ ! -f "$file" ]; then
echo "File $file not found."
return 1
exit 1
fi
# Set engine based on file if engine is not set
@ -77,7 +77,17 @@ check_file() {
esac
fi
# Output the file and engine being used
echo "Using $file with engine $engine"
if ! command -v "$engine" &> /dev/null
then
echo "$engine Not found. Please install $engine or use a different engine. Specify with --engine=engine_name"
exit 1
fi
}
check_file "$@"
# Output the file and engine being used
echo "Using $file with engine $engine"