#!/bin/bash

if [ ! -d .git ];
then
	echo "in a git directory plz"
	exit 0
fi


if [ $# -ne 0 ] && [ -e "$1" ]
then
    "/c/Program Files/Microsoft Visual Studio/2022/Professional/Common7/IDE/devenv.exe" $1  &
    exit 0
fi


echo "solution detection"
find . -name "*.sln" | while IFS= read -r line; do
    C="vs2022 $line"
    echo "$C"
    if [ $# -ne 0 ]
    then
        S="$1"
        if [[ "$line" == *"$S"* ]]
        then
            echo "    $S match"
            echo "    execute"
            eval $line
            exit 0
        fi
    fi
done
echo "try one above"
exit 0


