Skip to content

Commit

Permalink
✨ Add CLI
Browse files Browse the repository at this point in the history
  • Loading branch information
AnandChowdhary committed Sep 23, 2020
1 parent 4d3720e commit 4fdf977
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions src/cli.ts
Original file line number Diff line number Diff line change
@@ -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();

0 comments on commit 4fdf977

Please sign in to comment.