cli-sprintf-format
v1.1.1
Published
sprintf formatting targetted for CLI
Downloads
3,499,168
Maintainers
Readme
cli-sprintf-format
CLI dedicated sprintf formatter
An improved version of util.formatWithOptions
- Provides more reliable type resolution and error handling
- Detects color support (via supports-color)
- Ensures colored (if supported) output not only for the inspected objects but also for primitive vaulues
- Colored JSON (
%j) formatting - Object inspection depth defaults to
4, but can be overriden viaFORMAT_INSPECT_DEPTHenvironment variable - For
%sstrings are passed throughinspectformatter therefore appear colored (if supported) and eventual multiline content appears inline. To escape that behavior%#sshould be used instead
Installation
npm install cli-sprintf-formatUsage
const cliFormat = require("cli-sprintf-format");
console.log(cliFormat("Some %s with %d count", "foo", 12)); // Some foo with 12 countTests
npm test