Skip to content

Instantly share code, notes, and snippets.

@ciscoheat
Last active February 3, 2017 02:46
Show Gist options
  • Save ciscoheat/b1c780ba840bff0720bafd47489eaffe to your computer and use it in GitHub Desktop.
Save ciscoheat/b1c780ba840bff0720bafd47489eaffe to your computer and use it in GitHub Desktop.
Jot - Quick creation and execution of Haxe files
@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
@ciscoheat
Copy link
Author

ciscoheat commented Feb 2, 2017

How to use

Put the batch file somewhere in PATH. Then:

  1. jot init YourClass.hx to create the file YourClass.hx
  2. Hack away in YourClass.hx
  3. 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 then jot watch YourClass.hx for auto-compiling.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment