HootRunner.java
/**
* Copyright 2010,2021 Nikolas S Boyd.
Permission is granted to copy this work provided this copyright statement is retained in all copies.
*/
package Hoot.Tools;
import Hoot.Runtime.Functions.*;
import Hoot.Runtime.Faces.*;
import Hoot.Runtime.Values.*;
import Hoot.Runtime.Blocks.*;
import Smalltalk.Core.*;
import Smalltalk.Blocks.*;
import Smalltalk.Magnitudes.*;
import Hoot.Behaviors.*;
import Hoot.Behaviors.Nil;
import Hoot.Behaviors.Object;
import Hoot.Behaviors.True;
import Hoot.Behaviors.False;
import Hoot.Behaviors.Boolean;
import Hoot.Magnitudes.*;
import Hoot.Magnitudes.Integer;
import Hoot.Magnitudes.Character;
import Hoot.Magnitudes.Float;
import Hoot.Magnitudes.Double;
import Hoot.Collections.*;
import Hoot.Collections.String;
import java.util.*;
import Hoot.Streams.Transcript;
import Hoot.Runtime.Names.TypeName;
import Hoot.Runtime.Names.Selector;
import Hoot.Runtime.Names.Primitive;
import Hoot.Runtime.Functions.Utils;
import Hoot.Runtime.Blocks.MultiValuable;
import static Hoot.Runtime.Maps.Library.*;
import Hoot.Runtime.Behaviors.MethodCall;
public class HootRunner extends Object
{
public static Metaclass type() { return (Metaclass)Metaclass.$class; }
@Override public Metaclass $class() { return (Metaclass)Metaclass.$class; }
public static class Metaclass extends Object.Metaclass
{
static final HootRunner.Metaclass $class = new HootRunner.Metaclass();
public Metaclass() {
this(HootRunner.Metaclass.class);
}
public Metaclass(java.lang.Class aClass) {
super(aClass);
}
@Override public java.lang.Class outerClass() { return HootRunner.class; }
}
protected static final HootRunner Runner = new HootRunner();
/**
* @return
*/
public static void main(final java.lang.String ... args)
{
java.lang.String exitID = "HootRunner>>$main";
Frame f0 = new Frame(exitID);
Closure.with(f2 -> {
Runner.runWith(args);
}, "").runLoud();
}
/**
* @return
*/
public void runWith(final java.lang.String ... args)
{
java.lang.String exitID = "HootRunner>>runWith";
Frame f0 = new Frame(exitID);
List<String> argList = String.listWith(Utils.wrap(args));
if ((argList.size() == 0)) {
this.reportMissingClass();
}
else {
String className = argList.remove(0);
this.reportClass_with(className, argList);
this.run_with(className, argList);
};
}
/**
* @return
*/
public void run_with(final String className, final List<String> argList)
{
java.lang.String exitID = "HootRunner>>run_with";
Frame f0 = new Frame(exitID);
java.lang.Class aClass = TypeName.findPrimitiveClass(className.primitiveString());
if (MultiValuable.type().isAssignableFrom(aClass)) {
this.runNew_with(className, argList);
};
}
/**
* @return
*/
public void runNew_with(final String className, final List<String> argList)
{
java.lang.String exitID = "HootRunner>>runNew_with";
Frame f0 = new Frame(exitID);
List<java.lang.Object> args = new ArrayList();
args.addAll(argList);
MultiValuable mv = MethodCall.make(Selector.named(className.primitiveString()));
mv.runWith(args);
}
/**
* @return
*/
public Transcript log()
{
java.lang.String exitID = "HootRunner>>log";
Frame f0 = new Frame(exitID);
return (Transcript)Transcript.log();
}
/**
* @return
*/
public HootRunner reportMissingClass()
{
java.lang.String exitID = "HootRunner>>reportMissingClass";
Frame f0 = new Frame(exitID);
this.log().printLine(String.from("!! please specify a class name to run !!"));
return (HootRunner)this;
}
/**
* @return
*/
public HootRunner reportClass_with(final String className, final List<String> argList)
{
java.lang.String exitID = "HootRunner>>reportClass_with";
Frame f0 = new Frame(exitID);
this.log().cr();
this.log().print(String.from("running: ").append(className).append(String.from(" with: ")));
this.log().printLine(argList.toString());
return (HootRunner)this;
}
/**
* @return
*/
public String locationPath()
{
java.lang.String exitID = "HootRunner>>locationPath";
Frame f0 = new Frame(exitID);
return (String)String.from(Primitive.locateClass(this.getClass()).toString());
}
}