Translatetd cli to ts.

This commit is contained in:
SamTV12345 2024-02-11 21:21:25 +01:00
parent 253186daf5
commit 26b120caec
4 changed files with 27 additions and 8 deletions

View file

@ -21,33 +21,35 @@
*/
// An object containing the parsed command-line options
exports.argv = {};
import type {CliArgv} from "../types/CliArgv";
const argv = process.argv.slice(2);
export const argv:CliArgv = {};
const argvIn = process.argv.slice(2);
let arg, prevArg;
// Loop through args
for (let i = 0; i < argv.length; i++) {
arg = argv[i];
for (let i = 0; i < argvIn.length; i++) {
arg = argvIn[i];
// Override location of settings.json file
if (prevArg === '--settings' || prevArg === '-s') {
exports.argv.settings = arg;
argv.settings = arg;
}
// Override location of credentials.json file
if (prevArg === '--credentials') {
exports.argv.credentials = arg;
argv.credentials = arg;
}
// Override location of settings.json file
if (prevArg === '--sessionkey') {
exports.argv.sessionkey = arg;
argv.sessionkey = arg;
}
// Override location of APIKEY.txt file
if (prevArg === '--apikey') {
exports.argv.apikey = arg;
argv.apikey = arg;
}
prevArg = arg;