Example usage for jdk.nashorn.internal.runtime ScriptEnvironment getArguments

List of usage examples for jdk.nashorn.internal.runtime ScriptEnvironment getArguments

Introduction

In this page you can find the example usage for jdk.nashorn.internal.runtime ScriptEnvironment getArguments.

Prototype

public List<String> getArguments() 

Source Link

Document

Return the user arguments to the program, i.e.

Usage

From source file:z.zee.Z.java

License:Open Source License

/**
 * Run method logic.// ww  w  .j  ava  2s.c o  m
 *
 * @param in input stream for Z
 * @param out output stream for Z
 * @param err error stream for Z
 * @param args arguments to Z
 *
 * @return exit code
 *
 * @throws IOException if there's a problem setting up the streams
 */
protected final int run(final InputStream in, final OutputStream out, final OutputStream err,
        final String[] args) throws IOException {
    final Context context = makeContext(in, out, err, args);
    if (context == null) {
        return COMMANDLINE_ERROR;
    }

    final ScriptObject global = context.createGlobal();
    final ScriptEnvironment env = context.getEnv();
    final List<String> files = env.getFiles();

    if (env.getArguments().isEmpty() && !scripting) {
        context.getErr().println(bundle.getString("shell.usage"));
        return COMPILATION_ERROR;
    }

    if (files.isEmpty()) {
        return readEvalPrint(context, global);
    }

    if (env._compile_only) {
        return compileScripts(context, global, files);
    }

    return runScripts(context, global, files);
}