koneko-cli
Version:
Your CLI for reading manga from the terminal
66 lines (65 loc) • 2.44 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.MangaCLI = void 0;
const chalk_1 = __importDefault(require("chalk"));
const inquirer_1 = __importDefault(require("inquirer"));
const figlet_1 = __importDefault(require("figlet"));
const gradient_string_1 = __importDefault(require("gradient-string"));
const boxen_1 = __importDefault(require("boxen"));
const commander_1 = require("commander");
const Settings_1 = __importDefault(require("../modules/Settings")); // Assuming you have the Settings module
const Manga_1 = __importDefault(require("./events/Manga"));
class MangaCLI {
constructor() {
this.program = new commander_1.Command();
}
// Main entry point for the application
async run() {
console.clear();
await this.displayHeader();
await this.mainMenu();
}
// Displays header with CLI branding
async displayHeader() {
const figletText = figlet_1.default.textSync('Koneko', {
horizontalLayout: 'default',
verticalLayout: 'default',
});
console.log(gradient_string_1.default.rainbow(figletText));
const msgBox = (0, boxen_1.default)(chalk_1.default.green('Welcome to Koneko'), {
padding: 1,
margin: 1,
borderStyle: 'double',
});
console.log(msgBox);
}
// Displays the main menu
async mainMenu() {
const answers = await inquirer_1.default.prompt([
{
type: 'list',
name: 'option',
message: 'What would you like to do?',
choices: ['Search Manga', 'Settings', 'Exit'],
},
]);
if (answers.option === 'Settings') {
const settings = new Settings_1.default();
await settings.manage(); // Handle settings and return to main menu after it's done
await this.mainMenu(); // Go back to the main menu
}
else if (answers.option === "Search Manga") {
const Manga = new Manga_1.default;
await Manga.manage();
await this.mainMenu();
}
else {
console.log(chalk_1.default.gray('Goodbye! 👋'));
process.exit(0);
}
}
}
exports.MangaCLI = MangaCLI;