We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Hello, I can add, but cannot remove submenu items. Please help. Maybe I'm just missing something, but I believe this should work.
const { Select, Input } = require('enquirer'); let submenuChoices = ['Option A', 'Option B', 'Option C', 'Back to Main Menu']; const mainMenu = () => { const mainMenuPrompt = new Select({ name: 'option', message: 'Select an option:', choices: [ 'Actions Menu', 'Add Action', 'Remove Action', 'Exit', ], }); mainMenuPrompt.run().then((choice) => { if (choice === 'Add Action') { addOption(); } else if (choice === 'Remove Action') { removeOption(); } else if (choice === 'Actions Menu') { submenu(mainMenu); } else if (choice === 'Exit') { console.log('Goodbye!'); } }); }; const addOption = () => { const prompt = new Input({ message: 'Enter a new option:', initial: 'New Option', }); prompt.run().then((newOption) => { submenuChoices.push(newOption); // Add to submenu console.log(`Added new option: ${newOption}`); mainMenu(); }); }; const removeOption = () => { const removePrompt = new Select({ name: 'remove', message: 'Select an option to remove:', choices: submenuChoices, // Use submenu choices for removal }); removePrompt.run().then((optionToRemove) => { // Remove from submenu choices submenuChoices = submenuChoices.filter((submenuOption) => submenuOption !== optionToRemove); console.log(`Removed option: ${optionToRemove}`); mainMenu(); }); }; const submenu = (backFunction) => { const submenuPrompt = new Select({ name: 'submenu', message: 'Submenu options:', choices: submenuChoices, }); submenuPrompt.run().then((selectedOption) => { if (selectedOption === 'Back to Main Menu') { backFunction(); } else { console.log(`Selected submenu option: ${selectedOption}`); submenu(backFunction); } }); }; mainMenu();
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Hello, I can add, but cannot remove submenu items. Please help. Maybe I'm just missing something, but I believe this should work.
The text was updated successfully, but these errors were encountered: