Last active
February 3, 2017 02:46
-
-
Save ciscoheat/b1c780ba840bff0720bafd47489eaffe to your computer and use it in GitHub Desktop.
Jot - Quick creation and execution of Haxe files
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@echo off | |
setlocal enabledelayedexpansion | |
if [%1]==[] goto usage | |
if [%1]==[init] goto init | |
if [%1]==[watch] goto watch | |
for %%i in ("%1") do ( | |
set filepath=%%~di%%~pi | |
set filename=%%~ni | |
) | |
:: Throw the file parameter away | |
shift | |
set params=%1 | |
:loop | |
shift | |
if [%1]==[] goto afterloop | |
set params=%params% %1 | |
goto loop | |
:afterloop | |
haxe --interp -cp %filepath% -main %filename% %params% | |
goto end | |
:init | |
if [%2]==[] goto usage | |
set file=%2 | |
set tab= | |
for %%i in ("%file%") do ( | |
set filename=%%~ni | |
) | |
if exist "%2" ( | |
echo Error: %2 already exists. Delete it before using init. | |
goto end | |
) | |
(echo import sys.*; & echo import sys.io.*; & echo. & echo using Lambda; & echo using StringTools; & echo. & echo class %filename% { & echo %tab%static function main^(^) { & echo %tab%%tab%trace^('Jot'^); & echo %tab%} & echo }) > %file% | |
goto end | |
:watch | |
if [%2]==[] ( | |
echo Error: No file specified to watch. | |
goto end | |
) | |
nodemon -e "hx" -x "jot %2 %3 %4 %5 %6 %7 %8 %9" | |
goto end | |
:usage | |
echo Usage: jot [init|watch] FileName.hx [haxe params...] | |
:end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
How to use
Put the batch file somewhere in
PATH
. Then:jot init YourClass.hx
to create the fileYourClass.hx
YourClass.hx
jot YourClass.hx
to run with neko, append compiler parameters and arguments as needed.If you have Node.js installed, you can
npm install nodemon -g
and thenjot watch YourClass.hx
for auto-compiling.