diff --git a/README.md b/README.md index e9684a35..458997d6 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,6 @@ Thank you for using Prosperon! Provided are prosperon builds for all available platforms. Simply run prosperon for your platform in a game folder to play! -To get started, take a dive into the provided example games in the examples folder. Just copy the prosperon executable for your platform, into any provided example folder, then run it! +To get started, take a dive into the provided example games in the examples folder. You can either copy the prosperon executable into an example directory and run it there, or run `prosperon path/to/example` from the project root. You can take a look through the docs folder for the prosperon manual to learn all about it. The manual is available on the web at [docs.prosperon.dev](https://docs.prosperon.dev). diff --git a/scripts/modules/cmd.js b/scripts/modules/cmd.js index f506354c..fa9708b2 100644 --- a/scripts/modules/cmd.js +++ b/scripts/modules/cmd.js @@ -163,6 +163,9 @@ Cmdline.register_order( "spawn", function(argv) { prosperon.args = parse_args(argv) + if (!prosperon.args.cwd) prosperon.args.cwd = '.' + io.mount(prosperon.args.cwd) + if (!prosperon.args.program) os.exit() }, @@ -214,8 +217,19 @@ function cmd_args(cmds) { cmds.unshift("--program"); cmds.unshift("spawn"); } else if (!Cmdline.orders[cmds[0]]) { - // If the first token isn't a recognized command, treat it as a script - cmds.unshift("--program"); + // If the first token isn't a recognized command, treat it as either + // a directory containing main.js, or a script to run directly. + var arg0 = cmds.shift(); + if (io.is_directory(arg0)) { + var script = cmds[0] ? cmds.shift() : "main.js"; + cmds.unshift(script); + cmds.unshift("--program"); + cmds.unshift(arg0); + cmds.unshift("--cwd"); + } else { + cmds.unshift(arg0); + cmds.unshift("--program"); + } cmds.unshift("spawn"); }