
Security News
The Hidden Blast Radius of the Axios Compromise
The Axios compromise shows how time-dependent dependency resolution makes exposure harder to detect and contain.
ogmatrix-input
Advanced tools
A easy and modern npm package that controls users inputs to prompt the user in cmd.

ogmatrix-input is a modern, interactive command-line input utility for Node.js applications. It provides a rich and user-friendly experience for gathering various types of input, such as text, numbers, and selections, from the terminal. This library leverages the readline module to handle input efficiently and supports custom formatting and validation.
To install ogmatrix-input, use npm:
npm install ogmatrix-input
import { Input } from 'ogmatrix-input';
const input = new Input();
(async () => {
const response = await input.prompt({
type: "text",
q: "What is your name?",
required: true
});
console.log(response);
})();
const input = new Input();
(async () => {
const response = await input.prompt({
type: "number",
q: "Enter your age:",
required: true
});
console.log(response);
})();
const input = new Input();
(async () => {
const choices = ['Option 1', 'Option 2', 'Option 3'];
const response = await input.selection({
type: "single",
choices,
q: "Choose an option:"
});
console.log(response);
})();
const input = new Input();
(async () => {
const response = await input.pwd({
q: "Enter your password",
});
console.log(response);
})();
const input = new Input();
(async () => {
const response = await input.bool({
q: "Do you want to continue?",
default_bool: true
});
console.log(response);
})();
const input = new Input();
(async () => {
const response = await input.filedialog({
type: "file",
q: "Select your config file"
});
console.log(response);
})();
The design setting allows you to customize the appearance of the prompt. The available design options are:
Design.Simple: A basic design with minimal styling.Design.Modern: A stylish design with shadows and colors.Design.Colorful: A vibrant design with multiple colors.You can customize the colors used in the prompt box and its shadow:
box_color: The color of the prompt box.shadow_color: The color of the shadow effect.Example configuration for design parameter:
{
header: Design.Modern,
body: Design.Modern,
colors: {
box_color: Colors.foreground.white,
shadow_color: Colors.foreground.gray
}
}
const input = new Input();
(async () => {
const response = await input.prompt({
type: "text",
q: "Enter your favorite color:",
format: "text",
design: {
header: Design.Modern,
body: Design.Modern,
colors: {
box_color: Colors.foreground.white,
shadow_color: Colors.foreground.gray
}
}
});
console.log(`Your favorite color is ${response}`);
})();
promptThe prompt method is used to gather text or number input from the user.
"text" | "number" - The type of input to prompt for.string - The question to display to the user.boolean - Whether the input is required."json" | "text" - The format of the returned data (default: "json").InputPromptDesignSettings - Custom design settings for the prompt.Promise<string | InputJsonOutput | null> - The user's input in the specified format.selectionThe selection method is used to gather a selection from a list of choices.
"single" - The type of selection (currently supports only "single").string[] - The list of choices to present to the user.string - The question to display to the user."json" | "text" - The format of the returned data (default: "json").InputSelectionDesignSettings - Custom design settings for the prompt.Promise<string | InputJsonOutput | null> - The selected choice in the specified format.pwdThe pwd method is used to gather a password.
string - The question to display to the user.boolean - Whether the input is required."json" | "text" - The format of the returned data (default: "json").InputPwdDesignSettings - Custom design settings for the prompt.Promise<string | InputJsonOutput | null> - The password in the specified format.boolThe bool method is used to gather a boolean.
string - The question to display to the user.boolean - Whether the input is required.boolean - What the default boolean should be."json" | "text" - The format of the returned data (default: "json").InputBoolDesignSettings - Custom design settings for the prompt.Promise<string | InputJsonOutput | null> - The boolean in the specified format.filedialogThe filedialog method is used to gather a file path.
string - The type you want to gather ("file" or "folder")string - The question or prompt to display to the user.string - Where the dialog will start at (default: "__dirname" (current file path) ).string - What extensions you want to filter. (default: "*", example: ".jpg,.png,.jpeg")boolean - Whether to show hidden folders (start with ".") (default: false)."json" | "text" - The format of the returned data (default: "json").InputFiledialogDesignSettings - Custom design settings for the prompt.Promise<string | InputJsonOutput | null> - The file path in the specified format.The library supports formatting the output as either JSON or plain text. By default, the output is formatted as JSON, but this can be changed by setting the format parameter in the methods.
The JSON format provides structured output with additional metadata.
Example:
{
"answer": "your_input_here",
"index": 1,
"choices": ["Option 1", "Option 2", "Option 3"]
}
Example for boolean:
{
"answer": "true",
"bool": true
}
The text format returns the raw input as a string.
Example:
your_input_here
const input = new Input();
(async () => {
const response = await input.prompt({
type: "text",
q: "Enter your favorite color:",
format: "text"
});
console.log(`Your favorite color is ${response}`);
})();
const input = new Input();
(async () => {
const choices = ['Red', 'Blue', 'Green'];
const response = await input.selection({
type: "single",
choices,
q: "Choose a color:",
format: "text"
});
console.log(`You chose ${response}`);
})();
const input = new Input();
(async () => {
const response = await input.pwd({
q: "Enter your password",
format: "text"
});
console.log(`Your password is ${response}`);
})();
const input = new Input();
(async () => {
const response = await input.bool({
q: "Do you want to continue?",
default_bool: true,
format: "text"
});
console.log(`Your boolean is ${response}`);
})();
const input = new Input();
(async () => {
const response = await input.filedialog({
type: "file",
q: "Choose your favourite image",
startPath: "E:/users/YOUR_USER/pictures",
showHiddenFolders: true,
extensions: ".png,.jpg,.jpeg,.avif",
format: "text"
});
console.log(`You chose ${response}`);
})();
This project is licensed under the MIT License.
By OGMatrix
Feel free to contribute, raise issues, or submit pull requests to improve this library. Happy coding!
FAQs
A easy and modern npm package that controls users inputs to prompt the user in cmd.
We found that ogmatrix-input demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
The Axios compromise shows how time-dependent dependency resolution makes exposure harder to detect and contain.

Research
A supply chain attack on Axios introduced a malicious dependency, plain-crypto-js@4.2.1, published minutes earlier and absent from the project’s GitHub releases.

Research
Malicious versions of the Telnyx Python SDK on PyPI delivered credential-stealing malware via a multi-stage supply chain attack.