-
Notifications
You must be signed in to change notification settings - Fork 1
/
cli.js
47 lines (41 loc) · 1.24 KB
/
cli.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
const { getConf } = require("./config.js");
const { importMyEdenredTransactions, init } = require("./engine.js");
let config;
const printSyncedAccounts = () => {
const actualData = config.get("actualSync");
if (!actualData) {
console.error("No syncing data found");
return;
}
console.info("The following accounts are linked to Actual:");
console.table(
Object.values(actualData).map((account) => ({
"Actual Account": account.actualName,
"Actual Account Id": account.actualAccountId,
"MyEdenred Account Id": account.myEdenredAccountId,
}))
);
};
/**
*
* @param {string} command
* @param {object} flags
* @param {string} flags.since
*/
module.exports = async (command, flags) => {
if (!command) {
console.log('Try "myedenredactual --help"');
process.exit();
}
config = getConf(flags.user || "default")
if (command === "config") {
console.log(`Config for this app is located at: ${config.path}`);
} else if (command == "init") {
init()
} else if (command === "import") {
await importMyEdenredTransactions();
} else if (command === "ls") {
printSyncedAccounts();
}
process.exit();
};