summaryrefslogtreecommitdiff
path: root/Collect-Command-Line.sh
diff options
context:
space:
mode:
Diffstat (limited to 'Collect-Command-Line.sh')
-rw-r--r--Collect-Command-Line.sh53
1 files changed, 53 insertions, 0 deletions
diff --git a/Collect-Command-Line.sh b/Collect-Command-Line.sh
new file mode 100644
index 0000000..61545b7
--- /dev/null
+++ b/Collect-Command-Line.sh
@@ -0,0 +1,53 @@
+# Get the absolute path of the directory where the current script is located
+SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
+# Switch to the script's directory, exit if it fails
+cd "$SCRIPT_DIR" || exit 1
+
+# Define the target path for the CLI tool
+cliPath=".Temp/Debug/JustEnoughVCS"
+
+# Check if the CLI already exists at the target path
+if [ ! -f "$cliPath" ]; then
+ # Check if the CommandLine directory exists in the parent directory
+ if [ -d "./../CommandLine/" ]; then
+ # Check if a built CLI executable already exists
+ if [ -f "./../CommandLine/.temp/deploy/bin/jv" ]; then
+ # Create the target directory (if it doesn't exist)
+ mkdir -p "$(dirname "$cliPath")"
+ # Copy the CLI executable to the target path
+ cp "./../CommandLine/.temp/deploy/bin/jv" "$cliPath"
+ # Add execute permission
+ chmod +x "$cliPath"
+ echo "CLI copied to $cliPath"
+ else
+ # Check if a deployment script exists
+ if [ -f "./../CommandLine/deploy.sh" ]; then
+ echo "Building CLI from deploy.sh..."
+ # Enter the CommandLine directory and execute the deployment script
+ (cd "./../CommandLine" && ./deploy.sh)
+ # Check if the CLI executable was generated after deployment
+ if [ -f "./../CommandLine/.temp/deploy/bin/jv" ]; then
+ # Create the target directory (if it doesn't exist)
+ mkdir -p "$(dirname "$cliPath")"
+ # Copy the newly built CLI executable
+ cp "./../CommandLine/.temp/deploy/bin/jv" "$cliPath"
+ # Add execute permission
+ chmod +x "$cliPath"
+ echo "CLI built and copied to $cliPath"
+ else
+ # CLI executable still not found after deployment, error and exit
+ echo "Error: ./../CommandLine/.temp/deploy/bin/jv Not Found after deployment!"
+ exit 1
+ fi
+ else
+ # Deployment script not found, error and exit
+ echo "Error: ./../CommandLine/deploy.sh Not Found!"
+ exit 1
+ fi
+ fi
+ else
+ # CommandLine directory not found, error and exit
+ echo "Error: ./../CommandLine/ Not Found!"
+ exit 1
+ fi
+fi