Usage - mirah/mirah GitHub Wiki
Similar to Ruby, running programs with Mirah can be easily handled with a single call from the command line. Unlike Ruby, however, Mirah can also compile programs into Java .class files that can then be packaged into a JAR file and consumed many different JVMs. To handle these two different tasks, the Mirah package contains two executables: mirah
for running scripts, and mirahc
for compiling scripts.
Run an inline script
Running a quick inline script through the mirah
runner is a great way to test pieces of code outside of your normal workflow. In this example, we use the -e
command line switch to pass our inline script to Mirah using single quotes:
mirah -e 'def result:String; "Hi!"; end; puts result;'
Run a saved script
Similarly, running a single script saved to disk through the mirah
runner can be easily achieved with a similar command line call. In this example, we create a test script called Test.mirah
, save it to disk, and then pass that script name to Mirah for evaluation:
# Test.mirah
def result:String
"Hi!"
end
puts result
$ mirah Test.mirah
Hi!
Compile an inline script
Compiling a quick inline script through the mirahc
compiler works the same way as the mirah
runner, only instead of directing it's output to the command line (or stdout), the compiler will direct it's output into a single file called DashE.class
. In this example, we use the same -e
command line switch to pass our inline script to Mirah using single quotes:
mirahc -e 'def result:String; "Hi!"; end; puts result;'
This should result in the creation of a complied DashE.class
in the current directory containing our inline script code.
Compile a saved script
Similar to running a saved script, compiling a single script works with a quick call to the mirahc
compiler. In this example, we create a test script called Test.mirah
, save it to disk, and then pass that script name to Mirah for compilation:
# Test.mirah
def result:String
"Hi!"
end
puts result
$ mirahc Test.mirah
Parsing...
Test.mirah
Inferring types...
Compiling...
Test.mirah
Done!
This should produce a file named Test.class
in the current directory containing our saved script code.
Compile a collection of scripts
(This section has yet to be completed. Feel free to add your own contributions to help complete it!)