kool-shell
🎤📺🎶 A minimal module to deal with shell
Features
- 1 dependency (support-color)
- Native promises from Nodejs
- Shell commands with silent & inherited stdio
- Ansi Colors + Auto-detects color support
- Log methods with 4 log levels
- User input with hidden input option
- List input with multiple or single choice
- Awesome emoji-based spinner
- Progressbar
- Create and add your own kool-shell plugins easily
- Cool emojis!
Requirements
- Node > 8
- npm > 5
- ANSI/VT100 compatible terminal
Installation
npm install --save kool-shell
Usage
Create a new kool-shell instance
const sh = sh // You can also use object destructuringconst warn colors =
Namespacing
It can be useful to not share kool-shell configuration and state when dealing with
multiple modules. You can specify a namespace using the kool-shell/namespaced
module.
const sh1 = 'MyModule'sh1sh1 const sh2 = sh2
Kool-shell features
All features are basically native plugins, always available in kool-shell.
See the Plugins section below to learn how to create & add your own plugins.
- Log - Log functions
- Colors - Add colors to your log messages
- Progressbar - Display a progressbar
- Spinner - Display a spinner
- Exec - Execute a promised shell command
- Input - User prompt with hidden input option
- Select - Select/Radio input
- Cleanup - Do some actions before exiting your app
- Exit - Simple alias of
process.exit(code)
Plugins
Add a plugin
Add a plugin with sh.use(plugin, [options])
.
You can specify options for your plugin.
const koolPlugin = sh
Create a plugin
Plugin template
moduleexports = { return { // kool-shell native features are always available from the sh object. // for instance, you can easily use colors using sh.colors method optsgray ? console : console } }
Two arguments will be passed when your plugin is used through sh.use()
:
sh
is the kool-shell instance usedopts
is the options object passed troughsh.use(plugin, options)
Your plugin need to be a function that return an object. When your plugin is used, the returned object will be merged into the api object of the kool-shell instance.
⚠️ Method/Property will be overiden if a new one has the same name. Namespace your plugin api if you use common method names
To do
- Test all native features
License
MIT.