|
1 | | -@echo off |
2 | | -set ACTION=%~1 |
3 | | - |
4 | | -if "init" == "%ACTION%" ( |
5 | | - goto :init |
6 | | -) else if "active" == "%ACTION%" ( |
7 | | - goto :activate |
8 | | -) else if "deactive" == "%ACTION%" ( |
9 | | - goto :deactivate |
10 | | -) else if "prepare" == "%ACTION%" ( |
11 | | - goto :prepare |
12 | | -) else if "build" == "%ACTION%" ( |
13 | | - goto :build |
14 | | -) else if "fmt" == "%ACTION%" ( |
15 | | - goto :fmt |
16 | | -) else if "clean" == "%ACTION%" ( |
17 | | - goto :clean |
18 | | -) else ( |
19 | | - goto :usage |
20 | | -) |
21 | | - |
22 | | -:init |
23 | | -virtualenv .env |
24 | | -goto :eof |
25 | | - |
26 | | -:activate |
27 | | -if not exist "%~dp0.env\Scripts\activate.bat" call:init |
28 | | -call %~dp0.env\Scripts\activate.bat |
29 | | -goto :eof |
30 | | - |
31 | | -:deactivate |
32 | | -if exist "%~dp0.env\Scripts\deactivate.bat" ( |
33 | | -call %~dp0.env\Scripts\deactivate.bat |
34 | | -) |
35 | | -goto :eof |
36 | | - |
37 | | -:prepare |
38 | | -if not exist "%~dp0.env\Scripts\pip.exe" call:activate |
39 | | -call %~dp0.env\Scripts\pip.exe install -r requirements.txt |
40 | | -goto :eof |
41 | | - |
42 | | -:build |
43 | | -if not exist "%~dp0.env\Scripts\pyinstaller.exe" call:prepare |
44 | | -call %~dp0.env\Scripts\pyinstaller.exe app.spec |
45 | | -goto :eof |
46 | | - |
47 | | -:fmt |
48 | | -if not exist "%~dp0.env\Scripts\yapf.exe" call:prepare |
49 | | -for %%d in (*.py) do ( |
50 | | - echo formatting... %%d |
51 | | - call %~dp0.env\Scripts\yapf.exe -i %%d |
52 | | -) |
53 | | -goto :eof |
54 | | - |
55 | | -:clean |
56 | | -if exist "%~dp0\build" rmdir/s/q build |
57 | | -if exist "%~dp0\dist" rmdir/s/q dist |
58 | | -goto :eof |
59 | | - |
60 | | -:usage |
61 | | -set space_2= |
62 | | -set space_4= |
63 | | -echo. |
64 | | -echo Usage cmd [command] |
65 | | -echo. |
66 | | -echo where [command] is one of: |
67 | | -echo %space_2%init %space_4%create new virtual env |
68 | | -echo %space_2%active %space_4%active virtual env |
69 | | -echo %space_2%deactive %space_4%deactive virtual env |
70 | | -echo %space_2%prepare %space_4%install all dependencies |
71 | | -echo %space_2%build %space_4%package exe file |
72 | | -echo %space_2%fmt %space_4%format all py files |
73 | | -echo %space_2%clean %space_4%clean |
| 1 | +@echo off |
| 2 | +set ACTION=%~1 |
| 3 | + |
| 4 | +if "init" == "%ACTION%" ( |
| 5 | + goto :init |
| 6 | +) else if "active" == "%ACTION%" ( |
| 7 | + goto :activate |
| 8 | +) else if "deactive" == "%ACTION%" ( |
| 9 | + goto :deactivate |
| 10 | +) else if "prepare" == "%ACTION%" ( |
| 11 | + goto :prepare |
| 12 | +) else if "build" == "%ACTION%" ( |
| 13 | + goto :build |
| 14 | +) else if "fmt" == "%ACTION%" ( |
| 15 | + goto :fmt |
| 16 | +) else if "clean" == "%ACTION%" ( |
| 17 | + goto :clean |
| 18 | +) else ( |
| 19 | + goto :usage |
| 20 | +) |
| 21 | + |
| 22 | +:init |
| 23 | +python -m venv .env |
| 24 | +goto :eof |
| 25 | + |
| 26 | +:activate |
| 27 | +if not exist "%~dp0.env\Scripts\activate.bat" call:init |
| 28 | +call %~dp0.env\Scripts\activate.bat |
| 29 | +goto :eof |
| 30 | + |
| 31 | +:deactivate |
| 32 | +if exist "%~dp0.env\Scripts\deactivate.bat" ( |
| 33 | +call %~dp0.env\Scripts\deactivate.bat |
| 34 | +) |
| 35 | +goto :eof |
| 36 | + |
| 37 | +:prepare |
| 38 | +if not exist "%~dp0.env\Scripts\pip.exe" call:activate |
| 39 | +call %~dp0.env\Scripts\pip.exe install -r requirements.txt |
| 40 | +goto :eof |
| 41 | + |
| 42 | +:build |
| 43 | +if not exist "%~dp0.env\Scripts\pyinstaller.exe" call:prepare |
| 44 | +call %~dp0.env\Scripts\pyinstaller.exe app.spec |
| 45 | +goto :eof |
| 46 | + |
| 47 | +:fmt |
| 48 | +if not exist "%~dp0.env\Scripts\yapf.exe" call:prepare |
| 49 | +for %%d in (*.py) do ( |
| 50 | + echo formatting... %%d |
| 51 | + call %~dp0.env\Scripts\yapf.exe -i %%d |
| 52 | +) |
| 53 | +goto :eof |
| 54 | + |
| 55 | +:clean |
| 56 | +if exist "%~dp0\build" rmdir/s/q build |
| 57 | +if exist "%~dp0\dist" rmdir/s/q dist |
| 58 | +goto :eof |
| 59 | + |
| 60 | +:usage |
| 61 | +set space_2= |
| 62 | +set space_4= |
| 63 | +echo. |
| 64 | +echo Usage cmd [command] |
| 65 | +echo. |
| 66 | +echo where [command] is one of: |
| 67 | +echo %space_2%init %space_4%create new virtual env |
| 68 | +echo %space_2%active %space_4%active virtual env |
| 69 | +echo %space_2%deactive %space_4%deactive virtual env |
| 70 | +echo %space_2%prepare %space_4%install all dependencies |
| 71 | +echo %space_2%build %space_4%package exe file |
| 72 | +echo %space_2%fmt %space_4%format all py files |
| 73 | +echo %space_2%clean %space_4%clean |
0 commit comments