-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added better utility scripts that are platform independent
- Loading branch information
Showing
9 changed files
with
250 additions
and
101 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,124 @@ | ||
@echo off | ||
setlocal enabledelayedexpansion | ||
|
||
REM Command line arguments processing | ||
if not "%~1"=="" ( | ||
set "choice=%1" | ||
goto process_choice_no_pause | ||
) | ||
|
||
REM Function to display the menu | ||
:show_menu | ||
cls | ||
echo. | ||
echo ============================================================== | ||
echo AplusTools Main Menu | ||
echo ============================================================== | ||
echo 1. Install pytest and run tests | ||
echo 2. Build the project | ||
echo 3. Clear dist directory and build | ||
echo 4. Install the newly built package | ||
echo 5. Run all steps in order (1, 2 ^& 4) | ||
echo 0. Exit | ||
echo ============================================================== | ||
echo. | ||
set /p choice="Enter your choice (0-5, or multiple choices): " | ||
|
||
goto process_choice | ||
|
||
REM Function to process the choice | ||
:process_choice | ||
setlocal enabledelayedexpansion | ||
for /l %%i in (0,1,31) do ( | ||
set "opt=!choice:~%%i,1!" | ||
if "!opt!" == "1" call :run_tests | ||
if "!opt!" == "2" call :build_project | ||
if "!opt!" == "3" call :clear_and_build | ||
if "!opt!" == "4" call :install_package | ||
if "!opt!" == "5" call :run_all | ||
if "!opt!" == "0" goto end | ||
) | ||
pause | ||
goto end | ||
|
||
REM Process choice without pause | ||
:process_choice_no_pause | ||
setlocal enabledelayedexpansion | ||
for /l %%i in (0,1,31) do ( | ||
set "opt=!choice:~%%i,1!" | ||
if "!opt!" == "1" call :run_tests | ||
if "!opt!" == "2" call :build_project | ||
if "!opt!" == "3" call :clear_and_build | ||
if "!opt!" == "4" call :install_package | ||
if "!opt!" == "5" call :run_all | ||
if "!opt!" == "0" goto end | ||
) | ||
goto end | ||
|
||
REM Function to run tests | ||
:run_tests | ||
@echo off | ||
REM Install pytest | ||
py -m pip install pytest | ||
|
||
REM Ensure test_data directory exists and is empty | ||
set "DIR=test_data" | ||
if exist "%DIR%" ( | ||
echo Clearing directory %DIR%... | ||
rmdir /s /q "%DIR%" | ||
) | ||
echo Creating directory %DIR%... | ||
mkdir "%DIR%" | ||
|
||
REM Run tests | ||
echo Running tests... | ||
pytest aplustools/tests | ||
echo Tests completed. | ||
exit /b | ||
|
||
REM Function to build the project | ||
:build_project | ||
@echo off | ||
echo Building the project... | ||
py -m build | ||
echo Build completed. | ||
exit /b | ||
|
||
REM Function to clear dist directory and build | ||
:clear_and_build | ||
@echo off | ||
echo Clearing dist directory... | ||
del /Q ".\dist\*.*" | ||
call :build_project | ||
exit /b | ||
|
||
REM Function to install the newly built package | ||
:install_package | ||
@echo off | ||
for %%F in (dist\*.whl) do ( | ||
py -m pip install "%%F" --force-reinstall | ||
) | ||
echo Package installation completed. | ||
exit /b | ||
|
||
REM Function to run all steps | ||
:run_all | ||
@echo off | ||
call :run_tests | ||
call :build_project | ||
call :install_package | ||
exit /b | ||
|
||
:end | ||
echo Exiting... | ||
endlocal | ||
exit /b | ||
|
||
REM Command line arguments processing | ||
if "%1" NEQ "" ( | ||
set "choice=%1" | ||
goto process_choice | ||
) | ||
|
||
REM Show the menu by default | ||
goto show_menu |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,125 @@ | ||
#!/bin/bash | ||
|
||
# Function to display the menu | ||
show_menu() { | ||
clear | ||
echo | ||
echo "==============================================================" | ||
echo " AplusTools Main Menu" | ||
echo "==============================================================" | ||
echo "1. Install pytest and run tests" | ||
echo "2. Build the project" | ||
echo "3. Clear dist directory and build" | ||
echo "4. Install the newly built package" | ||
echo "5. Run all steps in order (1, 2 & 4)" | ||
echo "0. Exit" | ||
echo "==============================================================" | ||
echo | ||
read -p "Enter your choice (0-5, or multiple choices): " choice | ||
process_choice | ||
} | ||
|
||
# Function to process the choice | ||
process_choice() { | ||
local len=${#choice} | ||
for (( i=0; i<$len; i++ )); do | ||
local opt=${choice:i:1} | ||
case $opt in | ||
1) run_tests ;; | ||
2) build_project ;; | ||
3) clear_and_build ;; | ||
4) install_package ;; | ||
5) run_all ;; | ||
0) end ;; | ||
*) echo "Invalid choice: $opt" ;; | ||
esac | ||
done | ||
pause | ||
end | ||
} | ||
|
||
# Function to process the choice without pause | ||
process_choice_no_pause() { | ||
local len=${#choice} | ||
for (( i=0; i<$len; i++ )); do | ||
local opt=${choice:i:1} | ||
case $opt in | ||
1) run_tests ;; | ||
2) build_project ;; | ||
3) clear_and_build ;; | ||
4) install_package ;; | ||
5) run_all ;; | ||
0) end ;; | ||
*) echo "Invalid choice: $opt" ;; | ||
esac | ||
done | ||
end | ||
} | ||
|
||
# Function to pause the script | ||
pause() { | ||
read -p "Press any key to continue..." -n1 -s | ||
} | ||
|
||
# Function to run tests | ||
run_tests() { | ||
# Install pytest | ||
python3 -m pip install pytest | ||
|
||
# Ensure test_data directory exists and is empty | ||
DIR="test_data" | ||
if [ -d "$DIR" ]; then | ||
echo "Clearing directory $DIR..." | ||
rm -rf "$DIR" | ||
fi | ||
echo "Creating directory $DIR..." | ||
mkdir "$DIR" | ||
|
||
# Run tests | ||
echo "Running tests..." | ||
pytest aplustools/tests | ||
echo "Tests completed." | ||
} | ||
|
||
# Function to build the project | ||
build_project() { | ||
echo "Building the project..." | ||
python3 -m build | ||
echo "Build completed." | ||
} | ||
|
||
# Function to clear dist directory and build | ||
clear_and_build() { | ||
echo "Clearing dist directory..." | ||
rm -rf dist/* | ||
build_project | ||
} | ||
|
||
# Function to install the newly built package | ||
install_package() { | ||
for file in dist/*.whl; do | ||
python3 -m pip install "$file" --force-reinstall | ||
done | ||
echo "Package installation completed." | ||
} | ||
|
||
# Function to run all steps | ||
run_all() { | ||
run_tests | ||
build_project | ||
install_package | ||
} | ||
|
||
# Function to end the script | ||
end() { | ||
echo "Exiting..." | ||
exit 0 | ||
} | ||
|
||
# Command line arguments processing | ||
if [ -n "$1" ]; then | ||
choice=$1 | ||
process_choice_no_pause | ||
else | ||
show_menu | ||
fi |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.