
Security News
The Changelog Podcast: Practical Steps to Stay Safe on npm
Learn the essential steps every developer should take to stay secure on npm and reduce exposure to supply chain attacks.
@totemish/shell
Advanced tools
Tools for styling up console output and prompting for user input. Dependency-free.
Totemish shell is a set of tools for styling the console output and prompting for user input.
npm i --save @totemish/shell
To prompt for user input, you need to call Shell.prompt(). You need to provide a question you want to ask. Optionally, you may provide a default value that will be referred to as an answer in case user gives no input, and a values array, that represents a set of values and at least one of them must be picked by user or they will be informed about invalid choice provided and prompted the same question once again. Prompt returns user answer, automatically resolving floats, numbers and boleans.
import { Shell } from '@totemish/shell';
// NOTE: Shell.prompt() method is asynchronous
Shell.prompt('Pick a number').then((a) => { // ? Pick a number
Shell.prompt('What?', 'Nothing').then((b) => { // ? What? (Nothing)
Shell.prompt('Lemon is yellow', true, [true, false]).then(); // ? Lemon is yellow? [true, false] (true)
});
});
import { Shell } from '@totemish/shell';
/**
* There are five default helper methods
*/
Shell.write('white');
Shell.warn('yellow');
Shell.success('green');
Shell.info('blue');
Shell.error('red');
/**
* Prints a blank line
*/
Shell.blank();
/**
* You can specify amount of blank lines to be printed
*/
Shell.blank(2);
/**
* You can apply three types of enhanced decoration - bold, underline and inverse
* The spread operator is optional but it removes the nasty TypeScript incompatibility anger
*/
Shell.success(...Shell.bold('bold green'));
Shell.warn(...Shell.underline('underlined yellow'));
Shell.info(...Shell.inverse('inversed blue'));
/**
* Shell.describe method prints out the contents of an array or an object in a nice coloured way
* Booleans are given in magenta color, numbers - in yellow, object keys - in cyan and strings - in green
*/
Shell.describe({
boolean: true,
number: 42,
object: {
string: 'green',
array: [
"each",
"item",
"is",
"green",
],
nestedObject: {
hello: 'world'
}
}
});
Shell.describe([1,4,3,2]);
You can disable awaiting prompt input by providing a --y flag when starting the process. If process.argv includes the --y flag, prompter will automatically apply default value if it is given, or an empty string ('').
You can disable applying colors to console output by providing a --no-color flag when starting the process. If process.argv includes the --no-color flag, writer will write output to console without any ASCI magic.
You can disable output to console by providing a --silent flag when starting the process. If process.argv includes the --silent flag, prompter will automatically apply default value if it is given, or an empty string ('') and writer will give no output to console.
You can apply several styles and wrap up everything like so:
import { Shell } from '@totemish/shell';
Shell.write(Shell.green('hello'), Shell.red(' world'));
FAQs
Tools for styling up console output and prompting for user input. Dependency-free.
We found that @totemish/shell demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer 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
Learn the essential steps every developer should take to stay secure on npm and reduce exposure to supply chain attacks.

Security News
Experts push back on new claims about AI-driven ransomware, warning that hype and sponsored research are distorting how the threat is understood.

Security News
Ruby's creator Matz assumes control of RubyGems and Bundler repositories while former maintainers agree to step back and transfer all rights to end the dispute.