-
Notifications
You must be signed in to change notification settings - Fork 14
/
make.bat
50 lines (40 loc) · 1.27 KB
/
make.bat
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
@echo off
if [%1] == [] goto help
REM This allows us to expand variables at execution
setlocal ENABLEDELAYEDEXPANSION
REM This will set DIFF as a list of staged files
set DIFF=
for /F "tokens=* USEBACKQ" %%A in (`git diff --name-only --staged "*.py" "*.pyi"`) do (
set DIFF=!DIFF! %%A
)
REM This will set DIFF as a list of files tracked by git
if [!DIFF!]==[] (
set DIFF=
for /F "tokens=* USEBACKQ" %%A in (`git ls-files "*.py" "*.pyi"`) do (
set DIFF=!DIFF! %%A
)
)
goto %1
:reformat
py -m autoflake --in-place --imports=aiohttp,discord,redbot !DIFF! || goto :eof
py -m isort !DIFF! || goto :eof
py -m black !DIFF!
goto :eof
:stylecheck
autoflake --check --imports aiohttp,discord,redbot !DIFF! || goto :eof
isort --check-only !DIFF! || goto :eof
black --check !DIFF!
goto :eof
:reformatblack
black !DIFF!
goto :eof
:help
echo Usage:
echo make ^<command^>
echo.
echo Commands:
echo reformat Reformat all .py files being tracked by git.
echo stylecheck Check which tracked .py files need reformatting.
echo newenv Create or replace this project's virtual environment.
echo syncenv Sync this project's virtual environment to Red's latest
echo dependencies.