mangakonekuto
Version:
Your CLI for reading manga from the terminal
81 lines (80 loc) • 3.48 kB
JavaScript
;
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
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
run() {
return __awaiter(this, void 0, void 0, function* () {
console.clear();
yield this.displayHeader();
yield this.mainMenu();
});
}
// Displays header with CLI branding
displayHeader() {
return __awaiter(this, void 0, void 0, function* () {
const figletText = figlet_1.default.textSync('Manga CLI', {
horizontalLayout: 'default',
verticalLayout: 'default',
});
console.log(gradient_string_1.default.rainbow(figletText));
const msgBox = (0, boxen_1.default)(chalk_1.default.green('Welcome to Manga CLI!'), {
padding: 1,
margin: 1,
borderStyle: 'double',
});
console.log(msgBox);
});
}
// Displays the main menu
mainMenu() {
return __awaiter(this, void 0, void 0, function* () {
const answers = yield 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();
yield settings.manage(); // Handle settings and return to main menu after it's done
yield this.mainMenu(); // Go back to the main menu
}
else if (answers.option === "Search Manga") {
const Manga = new Manga_1.default;
yield Manga.manage();
yield this.mainMenu();
}
else {
console.log(chalk_1.default.gray('Goodbye! 👋'));
process.exit(0);
}
});
}
}
exports.MangaCLI = MangaCLI;