-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathrgit.bat
More file actions
67 lines (57 loc) · 1.72 KB
/
rgit.bat
File metadata and controls
67 lines (57 loc) · 1.72 KB
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
@echo off
setlocal
rem Set the path to your Rust project's root directory
rem cd /d path\to\your\project
rem Check if any arguments are provided
if "%~1"=="" (
echo Error: No command provided. 2>nul
exit /b 1
)
rem Check if the first argument is a valid command
if "%~1"=="init" (
rem Run cargo with "init" command
start /b cargo run --bin init 2>nul
rem Wait for the Rust command to finish
:wait_init
timeout /t 1 /nobreak >nul
tasklist | find /i "cargo.exe" 2>nul >nul
if not errorlevel 1 goto wait_init
rem If cargo is no longer running, set the hidden attribute for the .rgit directory and exit
attrib +h ".rgit" 2>nul
popd
exit /b
) else if "%~1"=="add" (
rem Run cargo with "add" command and passed arguments
start /b cargo run --bin add %* 2>nul
rem Wait for the Rust command to finish
:wait_add
timeout /t 1 /nobreak >nul
tasklist | find /i "cargo.exe" >nul
if not errorlevel 1 goto wait_add
rem If cargo is no longer running, set the hidden attribute for the .rgit directory and exit
attrib +h ".rgit" 1>nul 2>nul
popd
exit /b
) else if "%~1"=="commit" (
rem Shift the arguments to handle the double dash properly
shift
shift
start /b cargo run --bin %* 2>nul
rem Wait for the Rust command to finish
:wait_commit
timeout /t 1 /nobreak >nul
tasklist | find /i "cargo.exe" >nul
if not errorlevel 1 goto wait_commit
rem If cargo is no longer running, set the hidden attribute for the .rgit directory and exit
attrib +h ".rgit" 1>nul 2>nul
popd
exit /b
)else if "%~1"=="status" (
start /b cargo run --bin status
exit /b
)else (
echo Error: Unknown command "%~1"
popd
exit /b 1
)
endlocal