mirror of
https://github.com/ION606/ion-cli.git
synced 2026-05-14 22:16:56 +00:00
34 lines
863 B
JavaScript
34 lines
863 B
JavaScript
|
|
#!/usr/bin/env node
|
||
|
|
|
||
|
|
import chalk from 'chalk';
|
||
|
|
import { getAndParse } from './startup/getAndParseArgs.js';
|
||
|
|
import animeMain from './anime/getAndSave.js';
|
||
|
|
import help from './help.js'
|
||
|
|
|
||
|
|
function executeCommand(command, content = null) {
|
||
|
|
return new Promise((resolve) => {
|
||
|
|
switch(command) {
|
||
|
|
case 'help': help(content);
|
||
|
|
resolve(true);
|
||
|
|
break;
|
||
|
|
|
||
|
|
case 'anime': resolve(animeMain(content));
|
||
|
|
break;
|
||
|
|
|
||
|
|
default: console.log(chalk.red("Unknown command! try using"), chalk.red.bold("ion --help"));
|
||
|
|
resolve(false);
|
||
|
|
}
|
||
|
|
});
|
||
|
|
}
|
||
|
|
|
||
|
|
async function main() {
|
||
|
|
const args = await getAndParse();
|
||
|
|
for (const i in args) {
|
||
|
|
// console.log(chalk.blue(i) + ": " + args[i])
|
||
|
|
const worked = await executeCommand(i, args[i]);
|
||
|
|
if (!worked) break;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
main();
|