Skip to content

Latest commit

 

History

History
69 lines (51 loc) · 1.84 KB

echo.md

File metadata and controls

69 lines (51 loc) · 1.84 KB

nodejsscriptDocs


nodejsscript / echo

Function: echo()

echo(message?, ...optionalParams?): ShellString

This is mixed function between bash’s echo and console.log. By default, works more like console.log with partial supports for styling mimic CSS and console.log in the web browser. See echo.css (internally uses css-in-console - npm).

The 'echo.use' provides more echo way, the first argument accepts options string starting with -:

  • -n: Don’t append new line
  • -1/-2: Outputs to stdout/stderr
  • -c: Don’t colorize output (e.g. objects)
  • -P: Outputs objects in prettier format
  • -R/-r: Starts/Ends rewritable mode (for spinners, progress bars, etc.). Mode can be ended with any other echo without -R.

There is also

// as console.log
const count = 5;
echo('count: %d', count);
// Prints: count: 5, to stdout
echo('count:', count);
// Prints: count: 5, to stdout
echo({ count });
// Prints: { count: 5 }, to stdout
echo(new Error("Test"));
// Prints: 'Error: Test', when `config.verbose= false`
echo("%cRed", "color: red");
// Prints 'Red' in red
echo.use("-R", "0%");
// …
echo.use("-r", "100%");
// combination
echo.use("-2cP", { a: "A" });
echo("Hi").to("./test.txt");
// Prints: 'Hi' & save to file 'test.txt'

Parameters

message?: any

The text to print.

• ...optionalParams?: any[]

Returns

ShellString

Returns processed string with additional utility methods like .to().

Returns processed string with additional utility methods like .to().

Param

The text to print.