-
Notifications
You must be signed in to change notification settings - Fork 0
/
-module.bat
119 lines (118 loc) · 2.81 KB
/
-module.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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
@echo off
:: Variables
set PARAM=%~1
set MODULE=%~2
set OS=win
set MODULE_PATH=.apicra\module\%MODULE%
set APICRA_CONFIG=.apicra\module\%MODULE%\apicra.txt
set VARIABLE_PATH=.apicra\variable\%MODULE%.txt
:: get Variable from File
IF "%MODULE%"=="" GOTO help
IF EXIST %MODULE_PATH% (
:: set PROJECT_VAR = < module\%CMD%.txt
:: ECHO Module %MODULE% exist
) ELSE (
:: ECHO Module %MODULE% not exist
:: GOTO end
)
::
:: install
if "%PARAM%"=="i" GOTO install
if "%PARAM%"=="install" GOTO install
:: remove
::if "%PARAM%"=="r" GOTO remove
::if "%PARAM%"=="remove" GOTO remove
if "%PARAM%"=="d" GOTO delete
if "%PARAM%"=="delete" GOTO delete
:: update
if "%PARAM%"=="u" GOTO update
if "%PARAM%"=="update" GOTO update
::
:help
echo all modules
dir module
echo %CMD% exist
echo %CMD% name
echo %CMD% install wordpress
echo %CMD% remove wordpress
GOTO end
::
:exist
IF EXIST "module\%MODULE%.txt" (
ECHO true
) ELSE (
ECHO false
)
GOTO end
::
:name
IF EXIST ".apicra\module\%MODULE%.txt" (
ECHO < .apicra\module\%CMD%.txt
) ELSE (
:: ECHO false
ECHO :: MODULE :: PATH :: ".apicra\module\%MODULE%.txt" :: Not Exist
)
GOTO end
::
:install
echo ::
echo :: Module :: %MODULE% :: Install
echo :: from https://github.com/apicra/%OS%-%MODULE%.git
if "%MODULE%"=="" GOTO model_empty
::mkdir .apicra
::echo model/%MODULE%/ >> .gitignore
git clone https://github.com/apicra/%OS%-%MODULE%.git .apicra\module\%MODULE% && echo :: %MODULE% is installed
:: Create config file
echo "" > %VARIABLE_PATH%
IF EXIST %VARIABLE_PATH% echo :: Module :: Variable for %MODULE% is created
::install_module_from_config
IF EXIST %APICRA_CONFIG% (
ECHO :: Module :: Install All modules from config file %APICRA_CONFIG%
GOTO install_module_from_config
) ELSE (
GOTO end
)
::
:install_module_from_config
for /f "delims==" %%a in (%APICRA_CONFIG%) do .apicra\-module.bat install %%a
GOTO end
::
:update
echo ::
echo :: Module :: Update :: %MODULE%
echo ::
if "%MODULE%"=="" GOTO model_empty
::mkdir .apicra
::echo model/%MODULE%/ >> .gitignore
git -C .apicra\module\%MODULE% pull origin master && echo :: Module :: %MODULE% :: is installed
GOTO end
::
:delete
echo ::
echo :: Module :: Delete :: %MODULE%
echo ::
if "%MODULE%"=="" GOTO model_empty
IF NOT EXIST %MODULE_PATH% GOTO model_not_exist
RMDIR /Q /S .apicra\module\%MODULE% && echo :: Module :: %MODULE% :: module folder is deleted
del /f .apicra\variable\%MODULE%.txt && echo :: Module :: %MODULE% :: config file is deleted
GOTO end
::
:model_not_exist
echo :: Module :: %MODULE% not exist
GOTO end
::
:model_empty
echo :: Module :: Third parameter "PROJECT" is empty
GOTO delete_example
::
:create_example
echo :: Module :: Create Example:
echo :: %CMD% create "username" "projectname"
GOTO end
::
:delete_example
echo :: Module :: Delete Example:
echo :: %CMD% delete "username" "projectname"
GOTO end
::
:end