TODO: Expose console options
166348
@Override
  protected void run() throws Exception {
    final ResourceLoader resourceLoader = new MojoResourceLoader(getRuntimeRealm(), getScriptpath());
    final Map<String, Object> context = createContext();
    final Map<String, Object> options = Maps.newHashMap();
    final ConsoleWindow console = getRuntime().createConsoleWindow();

    WindowHandle handle = console.open(getRuntimeRealm(), resourceLoader, context, options);
    handle.await();
  }
614657
function exposed(name) {
  name = name || _name;
  this.js = this.js || {};
  return this.js[name]
    ? this.js[name].join('\n')
    : '';
}
968455
function consoleHandler(record) {
  if (typeof console === 'undefined' || !console) {
    return;
  }
  record = /** @type {!LogRecord} */(record);
  var timestamp = new Date(record.getMillis());
  var msg =
      '[' + timestamp.getUTCFullYear() + '-' +
      padNumber(timestamp.getUTCMonth() + 1, 2) + '-' +
      padNumber(timestamp.getUTCDate(), 2) + 'T' +
      padNumber(timestamp.getUTCHours(), 2) + ':' +
      padNumber(timestamp.getUTCMinutes(), 2) + ':' +
      padNumber(timestamp.getUTCSeconds(), 2) + 'Z]' +
      '[' + record.getLevel().name + ']' +
      '[' + record.getLoggerName() + '] ' +
      record.getMessage();

  var level = record.getLevel().value;
  if (level >= Logger.Level.SEVERE.value) {
    console.error(msg);
  } else if (level >= Logger.Level.WARNING.value) {
    console.warn(msg);
  } else {
    console.log(msg);
  }
}
558872
function getOptions () {
  return {
    compress: ('compress' in program) ? program.compress : false,
    debug: ('debug' in program) ? program.debug : false,
    deploy: false,
    grep: ('grep' in program) ? program.grep : false,
    invert: ('invert' in program) ? program.invert : false,
    maps: ('maps' in program) ? program.maps : false,
    reload: ('reload' in program) ? program.reload : false,
    script: ('script' in program) ? program.script : false,
    serve: ('serve' in program) ? program.serve : false,
    watch: false
  };
}
620468
function init(debug) {
	debug.inspectOpts = {};

	const keys = Object.keys(exports.inspectOpts);
	for (let i = 0; i < keys.length; i++) {
		debug.inspectOpts[keys[i]] = exports.inspectOpts[keys[i]];
	}
}
1245374
function execute(args) {
    try {
        const currentOptions = options.parse(args)
        return executeOptions(currentOptions)
    } catch (error) {
        console.error(error.message)
        return 1
    }
}
710569
private void processGeneralOptions(Configuration conf,
      CommandLine line) {
    if (line.hasOption("fs")) {
      FileSystem.setDefaultUri(conf, line.getOptionValue("fs"));
    }

    if (line.hasOption("jt")) {
      conf.set("mapred.job.tracker", line.getOptionValue("jt"));
    }
    if (line.hasOption("conf")) {
      String[] values = line.getOptionValues("conf");
      for(String value : values) {
        conf.addResource(new Path(value));
      }
    }
    try {
      if (line.hasOption("libjars")) {
        conf.set("tmpjars", 
                 validateFiles(line.getOptionValue("libjars"), conf));
        //setting libjars in client classpath
        URL[] libjars = getLibJars(conf);
        if(libjars!=null && libjars.length>0) {
          conf.setClassLoader(new URLClassLoader(libjars, conf.getClassLoader()));
          Thread.currentThread().setContextClassLoader(
              new URLClassLoader(libjars, 
                  Thread.currentThread().getContextClassLoader()));
        }
      }
      if (line.hasOption("files")) {
        conf.set("tmpfiles", 
                 validateFiles(line.getOptionValue("files"), conf));
      }
      if (line.hasOption("archives")) {
        conf.set("tmparchives", 
                  validateFiles(line.getOptionValue("archives"), conf));
      }
    } catch (IOException ioe) {
      System.err.println(StringUtils.stringifyException(ioe));
    }
    if (line.hasOption('D')) {
      String[] property = line.getOptionValues('D');
      for(String prop : property) {
        String[] keyval = prop.split("=", 2);
        if (keyval.length == 2) {
          conf.set(keyval[0], keyval[1]);
        }
      }
    }
    conf.setBoolean("mapred.used.genericoptionsparser", true);
  }
1356987
function parseOptions(type, options) {
    const ret = {
        indentChar: " ",
        indentSize: 2,
        startIndent: 1,
        switchCase: 0,
    }

    if (Number.isSafeInteger(type)) {
        ret.indentSize = type
    } else if (type === "tab") {
        ret.indentChar = "\t"
        ret.indentSize = 1
    }
    if (Number.isSafeInteger(options.switchCase)) {
        ret.switchCase = options.switchCase
    }
    if (Number.isSafeInteger(options.startIndent)) {
        ret.startIndent = options.startIndent
    }

    return ret
}
1335036
function exec() {

  // NOTE: pardon this cli target to Couchpenter methods mapping,
  // needed to preserve backward compatibility w/ v0.1.x
  const FUNCTIONS = {
    setup: 'setUp',
    'setup-db': 'setUpDatabases',
    'setup-doc': 'setUpDocuments',
    'setup-doc-overwrite': 'setUpDocumentsOverwrite',
    teardown: 'tearDown',
    'teardown-db': 'tearDownDatabases',
    'teardown-doc': 'tearDownDocuments',
    reset: 'reset',
    'reset-db': 'resetDatabases',
    'reset-doc': 'resetDocuments',
    clean: 'clean',
    'clean-db': 'cleanDatabases',
    'warm-view': 'warmViews',
    'live-deploy-view': 'liveDeployView'
  };

  var actions = {
    commands: {
      init: { action: _init }
    }
  };

  _.keys(FUNCTIONS).forEach(function (task) {
    actions.commands[task] = { action: _task(FUNCTIONS[task]) };
  });

  cli.command(__dirname, actions);
}
443628
function () {
    return (
      typeof console !== "undefined" &&
      console.log && console.warn && console.error && (
        /* Chrome, Safari, Opera, IE 10. */
        P_OBJECT.toString.call(console) === "[object Console]" ||
        /* Node.js, Firefox, IE 8–9. */
        P_OBJECT.toString.call(console) === "[object Object]"
      )
    )
  }
901852
function(parsoidOptions, cliOpts) {
		// Handle the --help options
		var exit = false;
		if (cliOpts.trace === 'help') {
			console.error(ScriptUtils.traceUsageHelp());
			exit = true;
		}
		if (cliOpts.dump === 'help') {
			console.error(ScriptUtils.dumpUsageHelp());
			exit = true;
		}
		if (cliOpts.debug === 'help') {
			console.error(ScriptUtils.debugUsageHelp());
			exit = true;
		}
		if (cliOpts.genTest === 'help') {
			console.error(ScriptUtils.genTestUsageHelp());
			exit = true;
		}
		if (exit) {
			process.exit(1);
		}

		// Ok, no help requested: process the options.
		if (cliOpts.debug !== undefined) {
			// Continue to support generic debugging.
			if (cliOpts.debug === true) {
				console.warn("Warning: Generic debugging, not handler-specific.");
				parsoidOptions.debug = ScriptUtils.booleanOption(cliOpts.debug);
			} else {
				// Setting --debug automatically enables --trace
				parsoidOptions.debugFlags = ScriptUtils.splitFlags(cliOpts.debug);
				parsoidOptions.traceFlags = parsoidOptions.debugFlags;
			}
		}

		if (cliOpts.trace !== undefined) {
			if (cliOpts.trace === true) {
				console.warn("Warning: Generic tracing is no longer supported. Ignoring --trace flag. Please provide handler-specific tracing flags, e.g. '--trace pre,html5', to turn it on.");
			} else {
				// Add any new trace flags to the list of existing trace flags (if
				// any were inherited from debug); otherwise, create a new list.
				parsoidOptions.traceFlags = (parsoidOptions.traceFlags || []).concat(ScriptUtils.splitFlags(cliOpts.trace));
			}
		}

		if (cliOpts.dump !== undefined) {
			if (cliOpts.dump === true) {
				console.warn("Warning: Generic dumping not enabled. Please set a flag.");
			} else {
				parsoidOptions.dumpFlags = ScriptUtils.splitFlags(cliOpts.dump);
			}
		}

		if (cliOpts.genTest) {
			if (cliOpts.genTest === true) {
				console.warn("Warning: Generic test generation is not supported. Ignoring --genTest flag. Please provide handler-specific tracing flags, e.g. '--genTest ListHandler', to turn it on.");
			} else {
				if (cliOpts.genTest.slice(0,4) === 'dom:') {
					var domHandlers = new Set([
						'dom:dpload', 'dom:fostered', 'dom:process-fixups', 'dom:normalize',
						'dom:pwrap', 'dom:migrate-metas', 'dom:pres', 'dom:migrate-nls',
						'dom:dsr', 'dom:tplwrap', 'dom:dom-unpack', 'dom:tag:cite', 'dom:tag:poem',
						'dom:fixups', 'dom:media', 'dom:sections', 'dom:heading-ids', 'dom:lang-converter',
						'dom:strip-metas', 'dom:cleanup', 'dom:linkclasses', 'dom:redlinks',
						'dom:downgrade'
					]);
					parsoidOptions.generateFlags = {
						"handlers": ScriptUtils.splitFlags(cliOpts.genTest),
						"directory": cliOpts.genDirectory,
						"pageName": cliOpts.pageName,
						"fragments": cliOpts.genTestFragments
					};
					parsoidOptions.generateFlags.handlers.forEach(function(handler) {
						console.assert(domHandlers.has(handler),
							'No matching DOM handler named ' + handler + ' found, exiting.');
					});

				} else {
					var handlers = new Set([
						'QuoteTransformer', 'ListHandler', 'ParagraphWrapper',
						'TokenStreamPatcher', 'BehaviorSwitchHandler', 'SanitizerHandler',
						'PreHandler', 'NoInclude', 'IncludeOnly', 'OnlyInclude',
						'MigrateTemplateMarkerMetas',
					]);
					parsoidOptions.generateFlags = {
						"handler": cliOpts.genTest,
						"fileName": cliOpts.genTestOut
					};
					console.assert(handlers.has(parsoidOptions.generateFlags.handler),
						'No matching token handler named ' + parsoidOptions.generateFlags.handler + ' found, exiting.');
				}
			}
		}

		return parsoidOptions;
	}
1358298
function Doc(runner, options) {
  Base.call(this, runner, options);

  var indents = 2;

  function indent() {
    return Array(indents).join('  ');
  }

  runner.on(EVENT_SUITE_BEGIN, function(suite) {
    if (suite.root) {
      return;
    }
    ++indents;
    console.log('%s<section class="suite">', indent());
    ++indents;
    console.log('%s<h1>%s</h1>', indent(), utils.escape(suite.title));
    console.log('%s<dl>', indent());
  });

  runner.on(EVENT_SUITE_END, function(suite) {
    if (suite.root) {
      return;
    }
    console.log('%s</dl>', indent());
    --indents;
    console.log('%s</section>', indent());
    --indents;
  });

  runner.on(EVENT_TEST_PASS, function(test) {
    console.log('%s  <dt>%s</dt>', indent(), utils.escape(test.title));
    var code = utils.escape(utils.clean(test.body));
    console.log('%s  <dd><pre><code>%s</code></pre></dd>', indent(), code);
  });

  runner.on(EVENT_TEST_FAIL, function(test, err) {
    console.log(
      '%s  <dt class="error">%s</dt>',
      indent(),
      utils.escape(test.title)
    );
    var code = utils.escape(utils.clean(test.body));
    console.log(
      '%s  <dd class="error"><pre><code>%s</code></pre></dd>',
      indent(),
      code
    );
    console.log('%s  <dd class="error">%s</dd>', indent(), utils.escape(err));
  });
}
332570
function(e)
            {
                var target = e.target,
                    className = target.className || ''
                    ;

                function getValue(name)
                {
                    var r = new RegExp(name + '_(\\w+)'),
                        match = r.exec(className)
                        ;

                    return match ? match[1] : null;
                };

                var highlighter = getHighlighterById(findParentElement(target, '.syntaxhighlighter').id),
                    commandName = getValue('command')
                    ;

                // execute the toolbar command
                if (highlighter && commandName)
                    sh.toolbar.items[commandName].execute(highlighter);

                // disable default A click behaviour
                e.preventDefault();
            }
320694
public static void main(String[] args) {
        try {
            Console console = System.console();
            if (console == null) {
                System.out.println("This application can only be used from the command line.");
                System.exit(-1);
            }
            IConverter converter = asConverter(args);
            try {
                Logger logger = LoggerFactory.getLogger(StandaloneClient.class);
                sayHello(converter, logger, console);
                DocumentType[] documentTypes = configureConversion(console, converter.getSupportedConversions());
                console.printf("Enter '<source> [-> <target>]' for converting a file. Enter '\\q' for exiting this application.%n");
                String argument;
                do {
                    console.printf("> ");
                    argument = console.readLine();
                    if (argument != null) {
                        if (argument.equals("\\q")) {
                            break;
                        } else if (argument.equals("\\f")) {
                            documentTypes = configureConversion(console, converter.getSupportedConversions());
                        } else if (argument.trim().equals("")) {
                            continue;
                        }
                        int targetIndex = argument.indexOf("->");
                        String source = targetIndex == -1 ? argument : argument.substring(0, targetIndex);
                        File sourceFile = normalize(source);
                        if (!sourceFile.isFile()) {
                            console.printf("Input file does not exist: %s%n", sourceFile);
                            continue;
                        }
                        String target = targetIndex == -1 ? source + "." + extensionFor(documentTypes[1]) : argument.substring(targetIndex + 1);
                        File targetFile = normalize(target);
                        converter.convert(sourceFile).as(documentTypes[0])
                                .to(targetFile, new LoggingFileConsumer(sourceFile, logger)).as(documentTypes[1])
                                .schedule();
                        console.printf("Scheduled conversion: %s -> %s%n", sourceFile, targetFile);
                        logger.info("Converting {} to {}", sourceFile, targetFile);
                    } else {
                        logger.error("Error when reading from console.");
                    }
                } while (argument != null);
                sayGoodbye(converter, logger);
            } finally {
                converter.shutDown();
            }
            console.printf("The connection was successfully closed. Goodbye!%n");
        } catch (Exception e) {
            LoggerFactory.getLogger(StandaloneClient.class).error("The document conversion client terminated with an unexpected error", e);
            System.err.println(String.format("Error: %s", e.getMessage()));
            System.err.println("Use option -? to display a list of legal commands.");
            System.exit(-1);
        }
    }
1075906
function showUsage() {
    console.log('\n  Usage: ' + argv.$0.cyan, '[command]', '[options]'.grey);

    showCommands();
    showTasks();
    showOptions();

    console.log('');
}
313700
function(content, depth = 0, options = {}) {
    var i, indent, isBoolean, isNull, isObj, j, k, out, prefix, ref, v;
    if (arguments.length === 2) {
      options = depth;
      depth = 0;
    }
    if (options.separator == null) {
      options.separator = ' = ';
    }
    if (options.eol == null) {
      options.eol = !options.ssh && process.platform === "win32" ? "\r\n" : "\n";
    }
    out = '';
    indent = options.indent != null ? options.indent : '  ';
    prefix = '';
    for (i = j = 0, ref = depth; (0 <= ref ? j < ref : j > ref); i = 0 <= ref ? ++j : --j) {
      prefix += indent;
    }
    for (k in content) {
      v = content[k];
      // isUndefined = typeof v is 'undefined'
      isBoolean = typeof v === 'boolean';
      isNull = v === null;
      isObj = typeof v === 'object' && !isNull;
      if (isObj) {
        continue;
      }
      if (isNull) {
        out += `${prefix}${k}`;
      } else if (isBoolean) {
        out += `${prefix}${k}${options.separator}${(v ? 'true' : 'false')}`;
      } else {
        out += `${prefix}${k}${options.separator}${v}`;
      }
      out += `${options.eol}`;
    }
    for (k in content) {
      v = content[k];
      isNull = v === null;
      isObj = typeof v === 'object' && !isNull;
      if (!isObj) {
        continue;
      }
      out += `${prefix}${string.repeat('[', depth + 1)}${k}${string.repeat(']', depth + 1)}${options.eol}`;
      out += module.exports.stringify_multi_brackets(v, depth + 1, options);
    }
    return out;
  }
394356
function exposeThen(Browser, command) {
    var exposed = ['then', ucfirst(command)].join('');

    Browser.prototype[exposed] = function () {
        var args = arguments;
        ensureDriverCommand.call(this, command, 'exposeThen');

        this.then(function (next) {
            args = wrapArguments.call(this, args, chainCallback, next);
            this[command].apply(this, args);
        });

        return this;
    };
}