Skip to content

Commit

Permalink
feat(cli): pass remaining arguments to arx executable when --rungame …
Browse files Browse the repository at this point in the history
…is called
  • Loading branch information
meszaros-lajos-gyorgy committed Sep 1, 2023
1 parent 3bf0850 commit 44bba47
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
4 changes: 3 additions & 1 deletion src/bin/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ const args: AppArgs = minimist(process.argv.slice(2), {
const settings = new Settings()

if (args.rungame) {
await rungame(settings)
const otherArgs = process.argv.slice(2).filter((param) => !param.trim().startsWith('--rungame'))
await rungame(settings, otherArgs)
} else {
console.info('[info] cli: available commands: "--rungame"')
console.info('[info] cli: all other parameters will be passed to the arx executable')
}
4 changes: 2 additions & 2 deletions src/bin/rungame.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@ import { promisify } from 'node:util'
import { Settings } from '@src/Settings.js'
import { fileExists } from '@src/helpers.js'

export const rungame = async (settings: Settings) => {
export const rungame = async (settings: Settings, otherArgs: string[]) => {
const operatingSystem = os.platform()

if (operatingSystem !== 'win32' && operatingSystem !== 'linux') {
console.error(`[error] rungame: unsupported platform (expected "win32" or "linux", but got "${operatingSystem}")`)
return
}

const args = [`--loadlevel ${settings.levelIdx}`]
const args = [`--loadlevel ${settings.levelIdx}`, ...otherArgs]

let exeFile: string
switch (operatingSystem) {
Expand Down

0 comments on commit 44bba47

Please sign in to comment.