Compiling Scripts from Command Line

pnutsc command

C:\> pnutsc { -d directory | -o output_jar_file } { -v } { -main mainClass { -m moduleName } } { -prefix name }{ -no_proxy } { { -C base_directory } script_file | input_jar_file } ...

pnutsc command compiles the specified script_files or script files in the input_jar_files.

If -o output_jar_file is specified, compiled classes are saved in the output_jar_file. If output_jar_file exists, the compiled classes are added to the JAR file.

If no -o option is specified, compiled scripts are saved in a set of class files in the specified directory with -d option, or current directory if -d is not specified.

-v means verbose mode. Generated class names or class file names are printed.

If -no_proxy is specified, generated code does not depend on the pnuts.compiler package, but the code for method calls is not optimized.

If the -prefix name is set, the name is the common prefix of the class names.

D:\pnuts> pnutsc -o pnuts-precompiled.jar pnuts/util/*.pnut pnuts/lib/*.pnut pnuts/gui/*.pnut pnuts/regex/*pnut

If -C option is specified, it changes the current directory to base_directory and then compiles the script_files.

If -main option is specified, mainClass with main() method and run(Context) method is generated.

public class mainClass extends pnuts.lang.Runtime {
   public Object run(Context ctx){
      ctx.usePackage(module1);
      ctx.usePackage(module2);
      ...
      new className1().run((Context)ctx.clone());
      new className2().run((Context)ctx.clone());
      ...
   }
   public static void main(String args[]){
      Pnuts.set("$args", args);
      new mainClass().run(new Context());
   }
 }
Example: hello.pnut
println("hello")
C:\> pnutsc -o hello.jar -main Hello -m pnuts.lib hello.pnut
C:\> java -classpath "hello.jar;pnuts.jar;pnuts-modules.jar" Hello