streamlink / streamlink-twitch-gui

A multi platform Twitch.tv browser for Streamlink
https://streamlink.github.io/streamlink-twitch-gui/
MIT License
2.7k stars 204 forks source link

show the actual version number alongside the other version number #1021

Closed killertofus closed 2 months ago

killertofus commented 2 months ago

Checklist

Description

when you type streamlink-twitch-gui --version it shows nwjs 120.0.6099.129

streamlink-twitch-gui -v or something like that should show 2.5.2 or 2.5.2 nwjs 120.0.6099.129

bastimeyer commented 2 months ago

--version, similar to --help, is part of NW.js/Chromium, which is interpreted before any application code is loaded and executed, as well as any Chromium-relevant code itself. There is no way for application logic to work around that because it's interpreted right at the beginning when launching NW.js/Chromium.

Something could be added to print the version when using the -- --version arguments (two leading dashes)

diff --git a/src/app/nwjs/argv.js b/src/app/nwjs/argv.js
index 13b37f29..b49fda75 100644
--- a/src/app/nwjs/argv.js
+++ b/src/app/nwjs/argv.js
@@ -1,5 +1,5 @@
 import minimist from "minimist";
-import { argv as appArgv, filteredArgv, manifest, dataPath } from "nwjs/App";
+import { default as App, argv as appArgv, filteredArgv, manifest, dataPath } from "nwjs/App";
 import Parameter from "utils/parameters/Parameter";
 import ParameterCustom from "utils/parameters/ParameterCustom";
 import { dirname } from "path";
@@ -147,3 +147,8 @@ export function parseCommand( command ) {

 export const argv = minimist( appArgv, minimistOptions );
+
+if ( /(^|\s)--version(\s|$)/.test( argv[ "_" ] || "" ) ) {
+   process.stdout.write( `${manifest[ "name" ]} ${manifest[ "version" ] }\n` );
+   App.quit();
+}

but I don't think this is very useful, because it launches the entire application, just in order to read the version string from the manifest JSON.