From 4fdf977b0c56d449b3bfe8d0ea8eeadafd792006 Mon Sep 17 00:00:00 2001 From: Anand Chowdhary Date: Wed, 23 Sep 2020 20:55:32 +0530 Subject: [PATCH] :sparkles: Add CLI --- src/cli.ts | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 src/cli.ts diff --git a/src/cli.ts b/src/cli.ts new file mode 100644 index 0000000..9786cf7 --- /dev/null +++ b/src/cli.ts @@ -0,0 +1,36 @@ +#!/usr/bin/env node +import { + Spotify, + Rescuetime, + LastFm, + PocketCasts, + Wakatime, + Clockify, + GoogleFit, + OuraRing, + Goodreads, + Twitter, +} from "./"; + +const cli = async () => { + const command = process.argv[2]; + if (command === "migrate") { + const integration = process.argv[3]; + if (!integration) throw new Error("Provide an integration"); + const start = process.argv[4]; + if (!start) throw new Error("Provide a start date"); + + [Spotify, Rescuetime, LastFm, PocketCasts, Wakatime, Clockify, GoogleFit, OuraRing, Goodreads, Twitter].forEach( + (ClassName) => { + const integrationObject = new ClassName(); + if (integration === integrationObject.name) { + integrationObject.legacy(start); + } + } + ); + } else { + throw new Error(`CLI command '${command}' not recognized`); + } +}; + +cli();