Search in sources :

Example 1 with ScriptInterpreter

use of org.phoenicis.scripts.interpreter.ScriptInterpreter in project POL-POM-5 by PlayOnLinux.

the class PhoenicisTestsApp method testScript.

private void testScript(CategoryDTO categoryDTO, ApplicationDTO applicationDTO, ScriptDTO scriptDTO) {
    final ScriptInterpreter scriptInterpreter = applicationContext.getBean("nashornInterprpeter", ScriptInterpreter.class);
    System.out.print("| |-- " + scriptDTO.getScriptName());
    try {
        scriptInterpreter.runScript(scriptDTO.getScript(), e -> {
            throw new TestException(e);
        });
        System.out.println(" [OK] ");
    } catch (TestException e) {
        e.printStackTrace();
        System.out.println(" [KO] ");
    }
}
Also used : ScriptInterpreter(org.phoenicis.scripts.interpreter.ScriptInterpreter)

Example 2 with ScriptInterpreter

use of org.phoenicis.scripts.interpreter.ScriptInterpreter in project POL-POM-5 by PlayOnLinux.

the class CLIController method runScript.

@Option
@LongSwitch("script")
@ShortSwitch("s")
@AllAvailableArguments
public void runScript(List<String> arguments) {
    final String scriptPath = arguments.get(0);
    final File scriptFile = new File(scriptPath);
    final ScriptInterpreter scriptInterpreter = applicationContext.getBean("scriptInterpreter", ScriptInterpreter.class);
    scriptInterpreter.runScript(scriptFile, e -> {
        throw new IllegalStateException(e);
    });
}
Also used : ScriptInterpreter(org.phoenicis.scripts.interpreter.ScriptInterpreter) File(java.io.File) ShortSwitch(com.github.jankroken.commandline.annotations.ShortSwitch) Option(com.github.jankroken.commandline.annotations.Option) LongSwitch(com.github.jankroken.commandline.annotations.LongSwitch) AllAvailableArguments(com.github.jankroken.commandline.annotations.AllAvailableArguments)

Aggregations

ScriptInterpreter (org.phoenicis.scripts.interpreter.ScriptInterpreter)2 AllAvailableArguments (com.github.jankroken.commandline.annotations.AllAvailableArguments)1 LongSwitch (com.github.jankroken.commandline.annotations.LongSwitch)1 Option (com.github.jankroken.commandline.annotations.Option)1 ShortSwitch (com.github.jankroken.commandline.annotations.ShortSwitch)1 File (java.io.File)1