A lightweight Node.js package (v0.1.10) that reads a Markdown file or string and prints formatted usage text to the console when CLI help flags (-h, --help) are passed. It can automatically locate a usage.md file relative to the entry script or accept custom paths and Markdown strings. The package uses the 'marked' library for Markdown-to-terminal conversion. Last updated with minor dependency bumps, it is simple and dependency-light, but lacks active maintenance. Key differentiators: zero-config auto-detection of help flags and usage.md, plus a .get() API to retrieve compiled text without auto-printing.
npm install cli-usageVerified import paths — ran on the pinned version, not inferred.
Demonstrates basic usage: creating a usage function that prints a Markdown string when help flags are passed, and auto-detection of usage.md file.
Consider alternatives like 'commander' help or 'caporal' for CLI argument parsing with built-in help.
Use the .get() method manually and implement your own flag parsing instead of relying on the automatic behavior.
Always pass a file path or Markdown string explicitly.
Do not use in non-CLI modules. Use .get() to retrieve text without side effects.
Use require('cli-usage') and assign to a variable (var usage = require('cli-usage');).Specify a full or relative path to a Markdown file, e.g., usage('./path/to/usage.md').Add var usage = require('cli-usage'); at the top of your file.