@we-make-websites/tannoy v1.12.0
📢 Tannoy (Tny)
Simple terminal message outputting tool.
🖨 Printing messages
Tny.message(message, options)
Prints a message to the terminal.
{Array|String} message - Message to output, each item in the array is printed on a newline.
options
{Boolean} after- Add empty newline after message, defaults totrue{Boolean} before- Add empty newline before message, defaults tofalse{Boolean} empty- Clear terminal, defaults tofalse{Boolean} newline- Set tofalseto prevent moving cursor to newline, overridesafterwhenfalse
Shortcodes
These are tags which are dynamically replaced when generating the terminal message.
{{basis version}}- Replaced with current Basis version in its package.json{{canvas version}}- Replaced with current Canvas version in its package.json{{library version}}- Replaced with current Canvas Library Tools version in its package.json{{storybook version}}- Replaced with current Canvas Storybook Tools version in its package.json
Tny.clear({ clear, move })
Moves the cursor and clears the terminal.
clear
{String} clear.direction- Direction to clear in, acceptsall,before, orafter.{String} clear.type- Type of clear, acceptsscreenorline.
move
{String} move.direction- Direction to move, acceptsup,down,right, orleft.{Number} move.lines- Number of lines to move.
🎨 Formatting messages
Tny.colour(colour, string)
Returns provided string with selected colour based on value of colour. Does not output the string, you must use message() or add() for this.
colour supports the following strings as values:
| Text | Text (bright) | Background |
|---|---|---|
| black | brightBlack | bgBlack |
| red | brightRed | bgRed |
| green | brightGreen | bgGreen |
| yellow | brightYellow | bgYellow |
| blue | brightBlue | bgBlue |
| magenta | brightMagenta | bgMagenta |
| cyan | brightCyan | bgCyan |
| white | brightWhite | bgWhite |
Note: When using background colour values the text colour is automatically set to the most contrasting (usually black).
⏳ Loading spinner
Tny.spinner.start(options)
Starts a spinner that shows each frame with a message.
options
{Array} frames- Each item in array is used as a frame in the animation{Number} interval- Time in ms between each frame, defaults to100{String} message- Message to display after animation frame{Object} states- Contains the messages for various states which are accessed by the value ofstateinTny.spinner.stop(state)
Tny.spinner.stop(state)
Stops the spinner and replaces it with the message defined in states using state as the key to find it.
E.g. if states contained values for success and error then using Tny.spinner.stop('success') would display the success message.
🕑 Time
Tny.time(start, end)
Returns time taken with appropriate clock emoji where start is start time (or time taken in ms) and end is end time, both times should be ms from unix epoch.
📅 Changelog
See CHANGELOG.md for a history of changes.
🤝 Contribution
Before making any updates to Tannoy please talk to Craig Baldwin (craig@wemakewebsites.com)
Once any work is completed send a pull request to Craig for review.
4 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
3 years ago
4 years ago
4 years ago
4 years ago
4 years ago
3 years ago
3 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago