mirror of
https://github.com/ION606/ion-cli.git
synced 2026-05-14 22:16:56 +00:00
initial commit
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
#!/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();
|
||||
Reference in New Issue
Block a user