-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun.bat
More file actions
72 lines (59 loc) · 2.5 KB
/
run.bat
File metadata and controls
72 lines (59 loc) · 2.5 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
68
69
70
71
72
@echo off
REM run.bat — Windows wrapper for cobol-safe-translator
REM Usage: run.bat [path\to\program.cob]
REM Default: samples\hello.cob
setlocal enabledelayedexpansion
REM ── Resolve project root ────────────────────────────────────────
cd /d "%~dp0"
REM ── Check Python 3.11+ ─────────────────────────────────────────
where python >nul 2>&1
if errorlevel 1 (
echo ERROR: python not found on PATH. >&2
exit /b 1
)
python -c "import sys; exit(0 if sys.version_info >= (3, 11) else 1)"
if errorlevel 1 (
echo ERROR: Python 3.11+ required. >&2
exit /b 1
)
REM ── Check cobol2py is installed ─────────────────────────────────
where cobol2py >nul 2>&1
if errorlevel 1 (
echo ERROR: cobol2py not found. Install with: pip install -e . >&2
exit /b 1
)
REM ── Determine input file ────────────────────────────────────────
set "COBOL_FILE=%~1"
if "%COBOL_FILE%"=="" set "COBOL_FILE=samples\hello.cob"
if not exist "%COBOL_FILE%" (
echo ERROR: File not found: %COBOL_FILE% >&2
exit /b 1
)
REM ── Derive output directory from filename ───────────────────────
for %%F in ("%COBOL_FILE%") do set "BASENAME=%%~nF"
set "OUT_DIR=output\%BASENAME%"
echo === cobol-safe-translator ===
echo Input: %COBOL_FILE%
echo Output: %OUT_DIR%\
echo.
REM ── Run translate ───────────────────────────────────────────────
echo --- Translating to Python skeleton ---
cobol2py translate "%COBOL_FILE%" --output "%OUT_DIR%"
if errorlevel 1 (
echo ERROR: translate failed. >&2
exit /b 1
)
echo.
REM ── Run map ─────────────────────────────────────────────────────
echo --- Generating analysis reports ---
cobol2py map "%COBOL_FILE%" --output "%OUT_DIR%"
if errorlevel 1 (
echo ERROR: map failed. >&2
exit /b 1
)
echo.
REM ── Show output files ───────────────────────────────────────────
echo === Done ===
echo Output files:
dir /b "%OUT_DIR%\"
endlocal