Commands - Spicery/Nutmeg GitHub Wiki
Overview
Nutmeg can be used to write console-based commands. The @command
annotation is used to mark a procedure as the starting point for a console application, like this:
@command
def hello():
println( 'Hello, world!' )
enddef
If we compile the above program into a bundle called hello.bundle then we call it using the nutmeg command like this:
% nutmeg hello.bundle
Hello, world!
%
Multiple Commands
Bundle files can contain more than one entry-point. This can be useful when you want to pack several commands into a single bundle. In this case, you need to tell the nutmeg runner which @command
entry-point you want to run using the --entry-point
option:
% nutmeg --entry-point=hello hello.bundle
Hello, world!
%
N.B. You can only select procedures that have already been marked with @command
this way.
Note that a bundle file does not need to have any entry-points at all. This is appropriate when the bundle is a library file or is simply at an early point of development.