-
Notifications
You must be signed in to change notification settings - Fork 0
Running a Program
You can use the harlock language in three separate ways:
You can start the REPL for harlock by just typing harlock
into a shell;
Harlock v0.4.1 - amd64 on linux
>>> var hello = "Hello, world! 🐱"
>>> print(hello)
Hello, world! 🐱
>>>
To run a script, simply save an application into a text file and pass its name as the first argument into the harlock interpreter, like so:
harlock script.hlk
I generally use the .hlk
extension to define a harlock script.
Note that harlock fully supports UTF-8.
One cool thing (or at least I think it is!) that you can do with the harlock tool is that you can actually embed the whole harlock runtime together with the scripts, and produce one single statically linked go binary that contains every dependency you need to run your script.
This solves the problem of having to install an interpreter, having dependencies or access to the machine where you have to build everything. Instead of having all of those issues, you just ship a single binary.
Running harlock -help
reveals how to do it:
[~]$ harlock -help
usage: harlock [flags] [filename] [args]
Execute an harlock script or start a REPL session.
If the optional filename argument is passed, it must
be a valid name for an existing file, the contents of
which will be executed.
If a filename is passed, a number of additional args can
be passed, that will be available within the running
application through the args global variable. If no file
is passed, the interpreter starts in interactive-mode.
Flags:
-embed string
embed the input script into an executable
containing the interpreter runtime, instead
of running the script; this requires a local
go installation
-help
show the help message
-version
print the version for this build
So you can embed a harlock script into an executable together with the harlock runtime by using the embed
flag:
harlock -embed script.hlk
This is only possible if you have a local go installation (version >= 1.18).