{"id":18219,"library":"cli-usage","title":"cli-usage","description":"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.","status":"maintenance","version":"0.1.10","language":"javascript","source_language":"en","source_url":"https://github.com/mikaelbr/cli-usage","tags":["javascript","CLI-Usage","Markdown","Usage","CLI","Print-Usage"],"install":[{"cmd":"npm install cli-usage","lang":"bash","label":"npm"},{"cmd":"yarn add cli-usage","lang":"bash","label":"yarn"},{"cmd":"pnpm add cli-usage","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Converts Markdown to terminal-formatted text (e.g., bold, code blocks).","package":"marked","optional":false}],"imports":[{"note":"Package uses CommonJS only; ESM import may fail unless using a bundler or Node.js with --experimental-require-module.","wrong":"import usage from 'cli-usage';","symbol":"default (usage function)","correct":"var usage = require('cli-usage');"},{"note":".get() is a method on the exported function object, not a separate named export.","wrong":"import { get } from 'cli-usage';","symbol":".get() method","correct":"var usage = require('cli-usage');\nvar text = usage.get('# markdown');"},{"note":"The function accepts a string (file path or Markdown content); passing an object will be ignored.","wrong":"usage({ path: './path/to/usage.md' });","symbol":"usage function with argument","correct":"var usage = require('cli-usage');\nusage('./path/to/usage.md');"}],"quickstart":{"code":"var usage = require('cli-usage');\n\n// Print usage from a Markdown string when --help is passed\nusage('# My CLI\\n\\nUsage: my-cli [options]\\n\\n## Options\\n- `-v` Show version\\n- `-h` Show help');\n\n// Or print usage automatically from usage.md (auto-detect if no argument given)\n// usage(); // looks for usage.md in script's directory","lang":"javascript","description":"Demonstrates basic usage: creating a usage function that prints a Markdown string when help flags are passed, and auto-detection of usage.md file."},"warnings":[{"fix":"Consider alternatives like 'commander' help or 'caporal' for CLI argument parsing with built-in help.","message":"Package hasn't received significant updates since 2016. Dependency 'marked' is outdated.","severity":"deprecated","affected_versions":">=0.1.0"},{"fix":"Use the .get() method manually and implement your own flag parsing instead of relying on the automatic behavior.","message":"The usage function listens for help flags globally and may conflict with other help handling.","severity":"gotcha","affected_versions":">=0.1.0"},{"fix":"Always pass a file path or Markdown string explicitly.","message":"If no argument is passed, it tries to find 'usage.md' relative to process.argv[1] (the script). If not found, nothing happens silently.","severity":"gotcha","affected_versions":">=0.1.0"},{"fix":"Do not use in non-CLI modules. Use .get() to retrieve text without side effects.","message":"Help flag detection triggers process.exit(0); this can be unexpected in a library context.","severity":"breaking","affected_versions":">=0.1.0"}],"env_vars":null,"search_vec":"'accept':45 'activ':78 'api':96 'auto':86,103 'auto-detect':85 'auto-print':102 'automat':34 'bump':68 'cli':2,25,107,111 'cli-usag':1,106 'compil':99 'config':84 'consol':23 'convers':62 'custom':46 'depend':67,74 'dependency-light':73 'detect':87 'differenti':81 'entri':42 'file':13,38 'flag':27,90 'format':18 'get':95 'h':28 'help':26,29,89 'javascript':105 'key':80 'lack':77 'last':63 'librari':56 'light':75 'lightweight':5 'locat':35 'mainten':79 'mark':55 'markdown':12,49,59,109 'markdown-to-termin':58 'minor':66 'node.js':6 'packag':7,52 'pass':31 'path':47 'plus':93 'print':17,104,113 'print-usag':112 'read':10 'relat':39 'retriev':98 'script':43 'simpl':71 'string':15,50 'termin':61 'text':20,100 'updat':64 'usag':3,19,108,110,114 'usage.md':37,92 'use':53 'v0.1.10':8 'without':101 'zero':83 'zero-config':82","created_at":"2026-04-25T07:37:05.334162+00:00","updated_at":"2026-04-25T07:37:05.334162+00:00","problems":[{"fix":"Use require('cli-usage') and assign to a variable (var usage = require('cli-usage');).","cause":"Using ES module import with 'import usage from \"cli-usage\"' in a CommonJS environment or vice versa.","error":"TypeError: usage is not a function"},{"fix":"Specify a full or relative path to a Markdown file, e.g., usage('./path/to/usage.md').","cause":"Calling usage() without a path and no usage.md exists in script's directory.","error":"ENOENT: no such file or directory, open 'usage.md'"},{"fix":"Add var usage = require('cli-usage'); at the top of your file.","cause":"Forgetting to require the package or scoping issue.","error":"ReferenceError: usage is not defined"}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":"usage","cli_version":null,"type":"library","homepage":null,"github":"https://github.com/mikaelbr/cli-usage","docs":null,"changelog":null,"pypi":null,"npm":"https://www.npmjs.com/package/cli-usage","openapi_spec":null,"status_page":null,"smithery":null,"categories":["devops"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-17","next_check":"2026-07-24","install_tag":null}}