Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a script to fetch a remote file #5

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 55 additions & 0 deletions bootstrap.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
@echo off
setlocal enabledelayedexpansion

set "DL_url=https://raw.githubusercontent.com/matortheeternal/TES5Edit/mator-zedit/"
set "folder=lib\xedit\"
set nocommit=false
::*********************************************************************************
:main
if "x%1"=="x" goto usage
if "x%1"=="xhelp" goto usage
if "x%1"=="xnocommit" (
set nocommit=true
shift
)
if "x%1"=="xall" (
call :all_files
) else (
call :single_file %1
)
if "%nocommit%"=="false" goto commit
exit /b
::*********************************************************************************
:single_file
set file=%1
call :Download %1
exit /b
::*********************************************************************************
:all_files
for /f "tokens=*" %%G in ('dir /B /s /a:-d "lib\xedit\*"') do (
set file_path=%%G
call :Download !file_path:%CD%\=!
)
exit /b
::*********************************************************************************
:Download <File_with_path>
set "file=%1"
set "file=%file:lib\xedit\=%"
set "URL=%DL_url%!file:\=/!"
echo Downloading file "%file%" from URL : "%URL%" to : "%1
rem Powershell.exe -command "(New-Object System.Net.WebClient).DownloadFile('%URL%','%1')"
exit /b
::*************************************************************************
:commit
echo.
echo Auto committing new files
git add lib\xedit\*
git commit -m "Update TES5Edit library"
exit /b
::*************************************************************************
:usage
echo Usage : %0 [nocommit] ^<all^|file^>
echo nocommit : By default, %0 will auto commit all new added files, this option let the user with uncommitted files
echo all : get all files from lib\xedit
echo file : get one file, give the path from git root i.e. lib\xedit\lz4\lz4.pas or lib\xedit\wbBAS.pas
exit /b