From 16320b92a58a0de2b3815053ba0bc6724271c5bd Mon Sep 17 00:00:00 2001 From: IDCs Date: Tue, 14 Jan 2025 08:57:16 +0000 Subject: [PATCH] Adding ability to import and install archives via cmdline closes nexus-mods/vortex#16896 --- src/extensions/download_management/index.ts | 10 +++++++++- src/util/commandLine.ts | 4 ++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/extensions/download_management/index.ts b/src/extensions/download_management/index.ts index 906903d18..71737b123 100644 --- a/src/extensions/download_management/index.ts +++ b/src/extensions/download_management/index.ts @@ -811,10 +811,18 @@ function processCommandline(api: IExtensionApi) { const { commandLine } = state.session.base; const cliUrl = commandLine.download ?? commandLine.install; - if (cliUrl) { api.events.emit('start-download-url', cliUrl, undefined, commandLine.install !== undefined); } + + const arcPath = commandLine.installArchive; + if (typeof arcPath === 'string' && path.isAbsolute(arcPath)) { + api.events.emit('import-downloads', [arcPath], (dlIds: string[]) => { + dlIds.forEach(dlId => { + api.events.emit('start-install-download', dlId); + }); + }); + } } function init(context: IExtensionContextExt): boolean { diff --git a/src/util/commandLine.ts b/src/util/commandLine.ts index 1d19b2582..adb60c976 100644 --- a/src/util/commandLine.ts +++ b/src/util/commandLine.ts @@ -10,6 +10,7 @@ import startupSettings from './startupSettings'; export interface IParameters { download?: string; install?: string; + installArchive?: string; installExtension?: string; report?: string; restore?: string; @@ -50,6 +51,7 @@ const ARG_COUNTS = { '-s': 1, '--download': 1, '--install': 1, + '--install-archive': 1, '--install-extension': 1, '--start-minimized': 1, '--game': 1, @@ -168,6 +170,7 @@ function parseCommandline(argv: string[], electronIsShitHack: boolean): IParamet + '(any supported protocol like nxm:, https:, ...).') .option('-i, --install ', 'Start downloadling & installing the specified url ' + '(any supported protocol like nxm:, https:, ...).') + .option('--install-archive ', 'Start installing the specified archive. Use absolute path.') .option('--install-extension ', 'Start downloadling & installing the specified ' + 'vortex extension. id can be "modId:".') .option('-g, --get ', 'Print the state variable at the specified path and quit. ' @@ -222,6 +225,7 @@ const SKIP_ARGS = { '--game': 1, '--profile': 1, '--install': 1, + '--install-archive': 1, '--install-extension': 1, '--restore': 1, '--merge': 1,