How to do a console application and get rid of the window?

Hi, I am new here,

I would like to know how to do do a console app using openfl. I read that I need to override the create method in my application class.

So could anyone show an “Hello World” example of how to do this?

haxe 3.4.2
openfl 3.6.1
lime 2.9.1

thanks,

This is possible – we use it for the OpenFL and Lime command-line tools.

The easiest example I know of are the OpenFL SWF processing tools.

First you need an HXML file, such as this one:

https://github.com/openfl/openfl/blob/develop/tools/tools.hxml

Instead of -cp .. you will want -lib openfl probably

The next thing is a Haxe class for your tools. There are two main components to this, the standard static function main entry point, but also the __init__ function if you need any of the Lime native binaries (which you will need if you do BitmapData methods)

https://github.com/openfl/openfl/blob/develop/tools/Tools.hx#L58-L135

https://github.com/openfl/openfl/blob/develop/tools/Tools.hx#L448

Lime has the lime.tools.helpers package, which has a lot of helpers we use in the command-line tools for Lime and OpenFL for running processes, creating directories, copying files and other useful utility functions.

I am interested in making this easier in the future, perhaps an official Lime command-line build target?

3 Likes

@singmajesty,

Wow, Thank you, It works!

An official Lime command-line build target would be nice!