Path: blob/main/core/dash-wasm/src/node-terminal.ts
1067 views
/*1dash-wasm [--worker] ...2*/34import { asyncDash, syncDash } from "./node";5import { supportsPosix } from "@cowasm/kernel";6import { Options } from "./common";78async function main() {9const { worker } = processArgs(process.argv);10if (process.platform == "win32") {11console.log("Press enter a few times.");12}13const options: Options = { interactive: true }; // todo -- what if not interactive (?)14const Dash = worker ? asyncDash : syncDash;15const dash = await Dash(options);16const argv = process.argv.slice(1);17let r = 0;18try {19// TODO: in async mode the worker thread itself just gets killed... See note about python in python-wasm/src/node-terminal.ts20r = await dash.terminal(argv);21} catch (_err) {}22if (argv.includes("-h")) {23console.log(`${process.argv[1]} [--worker] ...`);24console.log(25"--worker : use a worker thread, instead of single threaded version (NOTE: exit code is always 0)"26);27}28process.exit(r);29}3031function processArgs(argv: string[]): { worker: boolean } {32const j = argv.indexOf("--worker");33if (j != -1) {34argv.splice(j, 1);35}36let worker = false;37if (!supportsPosix()) {38worker = true;39} else {40worker = j != -1;41}42return { worker };43}4445main();464748