From 26b120caecb4598e0e917bdce510673a63a74738 Mon Sep 17 00:00:00 2001 From: SamTV12345 <40429738+samtv12345@users.noreply.github.com> Date: Sun, 11 Feb 2024 21:21:25 +0100 Subject: [PATCH] Translatetd cli to ts. --- src/node/types/CliArgv.ts | 6 ++++++ src/node/types/PadDiffLineOps.ts | 5 +++++ src/node/types/PadRevision.ts | 6 ++++++ src/node/utils/{Cli.js => Cli.ts} | 18 ++++++++++-------- 4 files changed, 27 insertions(+), 8 deletions(-) create mode 100644 src/node/types/CliArgv.ts create mode 100644 src/node/types/PadDiffLineOps.ts create mode 100644 src/node/types/PadRevision.ts rename src/node/utils/{Cli.js => Cli.ts} (80%) diff --git a/src/node/types/CliArgv.ts b/src/node/types/CliArgv.ts new file mode 100644 index 000000000..1c7f373b8 --- /dev/null +++ b/src/node/types/CliArgv.ts @@ -0,0 +1,6 @@ +export type CliArgv = { + settings?: string; + credentials?: string; + sessionkey?: string; + apikey?: string; +} diff --git a/src/node/types/PadDiffLineOps.ts b/src/node/types/PadDiffLineOps.ts new file mode 100644 index 000000000..9b1c4eb5d --- /dev/null +++ b/src/node/types/PadDiffLineOps.ts @@ -0,0 +1,5 @@ +export type PadDiffLineOps = { + next: ()=>PadDiffLineOps, + done: boolean, + value: PadDiffLineOps +} diff --git a/src/node/types/PadRevision.ts b/src/node/types/PadRevision.ts new file mode 100644 index 000000000..800d89bfd --- /dev/null +++ b/src/node/types/PadRevision.ts @@ -0,0 +1,6 @@ +export type PadRevision = { + changeset: string + meta:{ + author: string + } +} diff --git a/src/node/utils/Cli.js b/src/node/utils/Cli.ts similarity index 80% rename from src/node/utils/Cli.js rename to src/node/utils/Cli.ts index 1579dd3ce..dc63ecad7 100644 --- a/src/node/utils/Cli.js +++ b/src/node/utils/Cli.ts @@ -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;