Last active
May 7, 2025 03:10
-
-
Save pwd491/d812f1c62f99627aaa3d374d8564930d to your computer and use it in GitHub Desktop.
Download gitignore script
This file contains hidden or 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
@echo off | |
setlocal enabledelayedexpansion | |
:: Checking for arguments | |
if "%~1"=="" ( | |
echo Use: %~nx0 [arguments separated by commas] | |
echo Example: %~nx0 windows,python,visualstudiocode | |
echo List of available: %~nx0 list | |
exit /b 1 | |
) | |
:: Forming the URL from the arguments | |
set "params=%*" | |
set "params=!params: =,!" | |
set "url=https://www.toptal.com/developers/gitignore/api/!params!" | |
:: List of available arguments | |
if "%~1"=="list" ( | |
echo: | |
curl !url! | |
exit /b 1 | |
) | |
:: Download .gitignore | |
echo Downloading .gitignore for: !params! | |
curl --fail --silent --show-error !url! > .gitignore | |
:: Checking the success of the download | |
if %ERRORLEVEL% neq 0 ( | |
echo Error download .gitignore | |
del .gitignore 2>nul | |
exit /b 1 | |
) | |
:: Checking the file contents | |
findstr /i /c:"# Created by" .gitignore >nul | |
if %ERRORLEVEL% neq 0 ( | |
echo Got uncorrect .gitignore | |
type .gitignore | |
del .gitignore 2>nul | |
pause | |
exit /b 1 | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment