UNPKG

clitutor

Version:

Interactive CLI learning tool for beginners

101 lines (91 loc) • 4.01 kB
const inquirer = require('inquirer'); const chalk = require('chalk'); const boxen = require('boxen'); const figlet = require('figlet'); const ora = require('ora'); const chapter1 = require('./chapters/chapter1'); const chapter2 = require('./chapters/chapter2'); const chapter3 = require('./chapters/chapter3'); const chapter4 = require('./chapters/chapter4'); const chapter5 = require('./chapters/chapter5'); const chapter6 = require('./chapters/chapter6'); const { showMemo } = require('./memo'); const { showGitMemo } = require('./git-memo'); const { clearScreen, sleep } = require('./utils/helpers'); const green = chalk.hex('#00FF00'); const dim = chalk.dim; async function main() { clearScreen(); // Welcome screen with custom ASCII art console.log(green(` ________ ___ ___ _________ ___ ___ _________ ________ ________ |\\ ____\\ |\\ \\ |\\ \\ |\\___ ___\\|\\ \\|\\ \\ |\\___ ___\\|\\ __ \\ |\\ __ \\ \\ \\ \\___| \\ \\ \\ \\ \\ \\ \\|___ \\ \\_|\\ \\ \\\\\\ \\\\|___ \\ \\_|\\ \\ \\|\\ \\\\ \\ \\|\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\\\\\ \\ \\ \\ \\ \\ \\ \\\\\\ \\\\ \\ _ _\\ \\ \\ \\____ \\ \\ \\____ \\ \\ \\ \\ \\ \\ \\ \\ \\\\\\ \\ \\ \\ \\ \\ \\ \\\\\\ \\\\ \\ \\\\ \\| \\ \\_______\\\\ \\_______\\\\ \\__\\ \\ \\__\\ \\ \\_______\\ \\ \\__\\ \\ \\_______\\\\ \\__\\\\ _\\ \\|_______| \\|_______| \\|__| \\|__| \\|_______| \\|__| \\|_______| \\|__|\\|__| `)); console.log( boxen( chalk.white('Welcome to ') + green('clitutor') + chalk.white(' - Learn CLI Interactively!\n\n') + dim('A friendly tool to help you master the command line'), { padding: 1, margin: 1, borderStyle: 'round', borderColor: 'green' } ) ); await sleep(1500); // Main menu loop while (true) { console.log('\n' + dim('You can always exit using Ctrl+C to go back to your terminal\n')); const { action } = await inquirer.prompt([ { type: 'list', name: 'action', message: 'What would you like to do?', choices: [ { name: green('šŸ“š Chapter 1: Understanding Command Structure'), value: 'chapter1' }, { name: green('āŒØļø Chapter 2: Mastering Terminal Navigation'), value: 'chapter2' }, { name: green('šŸ“ Chapter 3: Navigating Your Digital World'), value: 'chapter3' }, { name: green('ā° Chapter 4: Git Basics - Your Personal Time Machine'), value: 'chapter4' }, { name: green('šŸ¤ Chapter 5: Git Collaboration - Working as a Team'), value: 'chapter5' }, { name: green('🄷 Chapter 6: Git Mastery - Power User Workflows'), value: 'chapter6' }, new inquirer.Separator(), { name: green('šŸŽÆ Command Memo - Quick Reference'), value: 'memo' }, { name: green('šŸ”„ Git Reference - Complete Git Guide'), value: 'git' }, new inquirer.Separator(), { name: 'šŸ‘‹ Exit', value: 'exit' } ] } ]); if (action === 'exit') { console.log(green('\n✨ Thanks for learning with clitutor! See you soon!\n')); process.exit(0); } else if (action === 'chapter1') { await chapter1.start(); } else if (action === 'chapter2') { await chapter2.start(); } else if (action === 'chapter3') { await chapter3.start(); } else if (action === 'chapter4') { await chapter4.start(); } else if (action === 'chapter5') { await chapter5.start(); } else if (action === 'chapter6') { await chapter6.start(); } else if (action === 'memo') { showMemo(); // Wait for user to press Ctrl+C await new Promise(() => {}); } else if (action === 'git') { showGitMemo(); // Wait for user to press Ctrl+C await new Promise(() => {}); } } } main().catch(console.error);