From 44bba470ad8cf9192cd2fbee26516550a6f77c49 Mon Sep 17 00:00:00 2001 From: Lajos Meszaros Date: Fri, 1 Sep 2023 19:18:02 +0200 Subject: [PATCH] feat(cli): pass remaining arguments to arx executable when --rungame is called --- src/bin/cli.ts | 4 +++- src/bin/rungame.ts | 4 ++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/bin/cli.ts b/src/bin/cli.ts index 2eee6f1e..08ae34a2 100644 --- a/src/bin/cli.ts +++ b/src/bin/cli.ts @@ -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') } diff --git a/src/bin/rungame.ts b/src/bin/rungame.ts index a7737e43..868adba6 100644 --- a/src/bin/rungame.ts +++ b/src/bin/rungame.ts @@ -5,7 +5,7 @@ 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') { @@ -13,7 +13,7 @@ export const rungame = async (settings: Settings) => { return } - const args = [`--loadlevel ${settings.levelIdx}`] + const args = [`--loadlevel ${settings.levelIdx}`, ...otherArgs] let exeFile: string switch (operatingSystem) {