Registry / devops / cli-usage

cli-usage

JSON →
library0.1.10jsnpmunverified

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-usage
INSTALL
IMPORT
SIG · CLI-USAGE
C
cli-usage
devopsjavascriptv0.1.10
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

default (usage function)
var usage = require('cli-usage');
import usage from 'cli-usage';
Package uses CommonJS only; ESM import may fail unless using a bundler or Node.js with --experimental-require-module.
.get() method
var usage = require('cli-usage'); var text = usage.get('# markdown');
import { get } from 'cli-usage';
.get() is a method on the exported function object, not a separate named export.
usage function with argument
var usage = require('cli-usage'); usage('./path/to/usage.md');
usage({ path: './path/to/usage.md' });
The function accepts a string (file path or Markdown content); passing an object will be ignored.

Demonstrates basic usage: creating a usage function that prints a Markdown string when help flags are passed, and auto-detection of usage.md file.

var usage = require('cli-usage'); // Print usage from a Markdown string when --help is passed usage('# My CLI\n\nUsage: my-cli [options]\n\n## Options\n- `-v` Show version\n- `-h` Show help'); // Or print usage automatically from usage.md (auto-detect if no argument given) // usage(); // looks for usage.md in script's directory
usage --version
Debug
Known issues
deprecatedPackage hasn't received significant updates since 2016. Dependency 'marked' is outdated.
fix
Consider alternatives like 'commander' help or 'caporal' for CLI argument parsing with built-in help.
affects: >=0.1.0
gotchaThe usage function listens for help flags globally and may conflict with other help handling.
fix
Use the .get() method manually and implement your own flag parsing instead of relying on the automatic behavior.
affects: >=0.1.0
gotchaIf no argument is passed, it tries to find 'usage.md' relative to process.argv[1] (the script). If not found, nothing happens silently.
fix
Always pass a file path or Markdown string explicitly.
affects: >=0.1.0
breakingHelp flag detection triggers process.exit(0); this can be unexpected in a library context.
fix
Do not use in non-CLI modules. Use .get() to retrieve text without side effects.
affects: >=0.1.0
Errors
Common errors & fixes
TypeError: usage is not a function
Using ES module import with 'import usage from "cli-usage"' in a CommonJS environment or vice versa.
fix
Use require('cli-usage') and assign to a variable (var usage = require('cli-usage');).
ENOENT: no such file or directory, open 'usage.md'
Calling usage() without a path and no usage.md exists in script's directory.
fix
Specify a full or relative path to a Markdown file, e.g., usage('./path/to/usage.md').
ReferenceError: usage is not defined
Forgetting to require the package or scoping issue.
fix
Add var usage = require('cli-usage'); at the top of your file.
Upgrade
Version history
0.1.10latest on npm
Audit
Dependencies
markedrequiredConverts Markdown to terminal-formatted text (e.g., bold, code blocks).
Agent activity
4 hits · last 30 days
node
4
Resources
cli-usage — npm install cli-usage · libregistry