nazarcpi
v1.0.1
Published
nazarteam
Downloads
4
Readme
Interactive CLI Tool
Interactive CLI Tool is a simple JavaScript library for building interactive command-line interfaces (CLIs) in Node.js applications. It provides functions to prompt users for input, display menus, and more.
Installation
You can install the library via npm:
npm install interactive-cli
Usage
const InteractiveCLI = require('interactive-cli');
async function main() {
const cli = new InteractiveCLI();
// Prompt for user input
const name = await cli.prompt('What is your name?');
console.log(`Hello, ${name}!`);
// Display a menu
const options = ['Option 1', 'Option 2', 'Option 3'];
const choiceIndex = await cli.menu(options);
console.log(`You chose: ${options[choiceIndex]}`);
// Close the CLI interface
cli.close();
}
main();
API
prompt(question)
Prompts the user with a question and returns their input as a Promise.
menu(options)
Displays a menu with the provided options and returns the index of the chosen option as a Promise.
close()
Closes the CLI interface, releasing associated resources.
License
This project is licensed under the MIT License - see the LICENSE file for details.