aboutsummaryrefslogtreecommitdiff
path: root/src/cli.js
diff options
context:
space:
mode:
author0neGal <mail@0negal.com>2022-01-19 23:48:17 +0100
committerGitHub <noreply@github.com>2022-01-19 23:48:17 +0100
commitae7de46f4748c800097f0f3c700e6525d7d7cc4f (patch)
tree5c66168894e5ad3b26e0330d24d62e1a985bea7c /src/cli.js
parent2ed4338b9608211c07c4dd620e7f3b073131388a (diff)
parentcc2fcbbdba49149724de7a07415d0dee23cc57d1 (diff)
downloadViper-ae7de46f4748c800097f0f3c700e6525d7d7cc4f.tar.gz
Viper-ae7de46f4748c800097f0f3c700e6525d7d7cc4f.zip
Merge pull request #46 from 0neGal/documentation
Adding documentation/comments
Diffstat (limited to 'src/cli.js')
-rw-r--r--src/cli.js19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/cli.js b/src/cli.js
index d5ee3ad..cef2295 100644
--- a/src/cli.js
+++ b/src/cli.js
@@ -8,6 +8,9 @@ const cli = app.commandLine;
const lang = require("./lang");
function hasArgs() {
+ // Makes sure the GUI isn't launched.
+ // TODO: Perhaps we should get a better way of doing this, at the
+ // very least we should use a switch case here.
if (cli.hasSwitch("cli") ||
cli.hasSwitch("help") ||
cli.hasSwitch("mods") ||
@@ -24,11 +27,20 @@ function hasArgs() {
} else {return false}
}
+// Exits the CLI, when run without CLI being on it'll do nothing, this
+// is needed as without even if no code is executed it'll continue to
+// run as Electron is still technically running.
function exit(code) {
if (hasArgs()) {process.exit(code)}
}
+// General CLI initialization
+//
+// A lot of the CLI is handled through events sent back to the main
+// process or utils.js to handle, this is because we re-use these events
+// for the renderer as well.
async function init() {
+ // --help menu/argument
if (cli.hasSwitch("help")) {
console.log(`options:
--help ${lang("cli.help.help")}
@@ -48,10 +60,14 @@ async function init() {
exit();
}
+ // --update
if (cli.hasSwitch("update")) {ipcMain.emit("update")}
+ // --version
if (cli.hasSwitch("version")) {ipcMain.emit("versioncli")}
+ // --setpath
if (cli.hasSwitch("setpath")) {
+ // Checks to verify the path is legitimate
if (cli.getSwitchValue("setpath") != "") {
ipcMain.emit("setpathcli", cli.getSwitchValue("setpath"));
} else {
@@ -60,6 +76,7 @@ async function init() {
}
}
+ // --launch
if (cli.hasSwitch("launch")) {
switch(cli.getSwitchValue("launch")) {
case "vanilla":
@@ -71,10 +88,12 @@ async function init() {
}
}
+ // Mod related args, --installmod, --removemod, --togglemod
if (cli.hasSwitch("installmod")) {ipcMain.emit("installmod")}
if (cli.hasSwitch("removemod")) {ipcMain.emit("removemod", "", cli.getSwitchValue("removemod"))}
if (cli.hasSwitch("togglemod")) {ipcMain.emit("togglemod", "", cli.getSwitchValue("togglemod"))}
+ // Prints out the list of mods
if (cli.hasSwitch("mods")) {ipcMain.emit("getmods")}
}