cli-sprintf-format

1.1.1 • Public • Published

Build status Tests coverage npm version

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 via FORMAT_INSPECT_DEPTH environment variable
  • For %s strings are passed through inspect formatter therefore appear colored (if supported) and eventual multiline content appears inline. To escape that behavior %#s should be used instead

Installation

npm install cli-sprintf-format

Usage

const cliFormat = require("cli-sprintf-format");

console.log(cliFormat("Some %s with %d count", "foo", 12)); // Some foo with 12 count

Tests

npm test

Package Sidebar

Install

npm i cli-sprintf-format

Weekly Downloads

938,185

Version

1.1.1

License

ISC

Unpacked Size

35.1 kB

Total Files

16

Last publish

Collaborators

  • medikoo