What is promzard?
Promzard is a Node.js module that allows you to create interactive command-line prompts for user input. It is particularly useful for creating configuration files or setting up project templates by asking users a series of questions and then generating the necessary files based on their responses.
What are promzard's main functionalities?
Interactive Prompts
This feature allows you to create interactive command-line prompts by specifying a configuration file. The user is prompted to answer questions, and the responses are used to generate a configuration object.
const promzard = require('promzard');
const path = require('path');
const file = path.resolve(__dirname, 'config.js');
promzard(file).then((result) => {
console.log('Configuration:', result);
}).catch((err) => {
console.error('Error:', err);
});
Default Values
You can provide default values for the prompts, which will be used if the user does not provide an input. This is useful for setting up common configurations quickly.
const promzard = require('promzard');
const path = require('path');
const file = path.resolve(__dirname, 'config.js');
const defaults = { name: 'defaultName', version: '1.0.0' };
promzard(file, defaults).then((result) => {
console.log('Configuration:', result);
}).catch((err) => {
console.error('Error:', err);
});
Custom Validation
Promzard allows you to add custom validation logic to the user inputs. This ensures that the configuration generated meets certain criteria before it is accepted.
const promzard = require('promzard');
const path = require('path');
const file = path.resolve(__dirname, 'config.js');
const validate = (input) => {
if (input.name.length < 3) {
throw new Error('Name must be at least 3 characters long');
}
return input;
};
promzard(file, {}, validate).then((result) => {
console.log('Configuration:', result);
}).catch((err) => {
console.error('Error:', err);
});
Other packages similar to promzard
inquirer
Inquirer.js is a collection of common interactive command-line user interfaces. It provides a more extensive set of features compared to Promzard, including support for various types of prompts (e.g., list, checkbox, password) and more advanced validation and formatting options.
prompt
The 'prompt' package is a simple, flexible, and powerful command-line prompt library for Node.js. It offers similar functionality to Promzard but with a focus on simplicity and ease of use. It supports schema-based prompts and asynchronous operations.
enquirer
Enquirer is a stylish, intuitive, and user-friendly prompt library for Node.js. It offers a rich set of features, including support for custom themes, advanced validation, and conditional prompts. Enquirer is designed to be highly customizable and easy to extend.
promzard
A reimplementation of @SubStack's
prompter, which does not
use AST traversal.
From another point of view, it's a reimplementation of
@Marak's
wizard which doesn't use schemas.
The goal is a nice drop-in enhancement for npm init
.
Usage
var promzard = require('promzard')
promzard(inputFile, optionalContextAdditions, function (er, data) {
})