remark-cli-help
Add cli help output to a README with remark.
Installation
npm:
npm install remark-cli-help
Usage
Dependencies:
const remark = require('remark');
const vfile = require('vfile');
const cliHelp = require('remark-cli-help');
Given a file:
const output = remark()
.use(cliHelp, {bin: 'remark'})
.processSync(vfile('## cli'))
.toString();
Yields:
## cli
```markdown
$ remark-cli-help --help
Usage: remark [options] [path | glob ...]
CLI to process Markdown with remark
Options:
-h --help output usage information
-v --version output version number
-o --output [path] specify output location
-r --rc-path <path> specify configuration file
-i --ignore-path <path> specify ignore file
-s --setting <settings> specify settings
-e --ext <extensions> specify extensions
-u --use <plugins> use plugins
-w --watch watch for changes and reprocess
-q --quiet output only warnings and errors
-S --silent output only errors
-f --frail exit with 1 on warnings
-t --tree specify input and output as syntax tree
--report <reporter> specify reporter
--file-path <path> specify path to process as
--ignore-path-resolve-from dir|cwd resolve patterns in `ignore-path` from its directory or cwd
--ignore-pattern <globs> specify ignore patterns
--silently-ignore do not fail when given ignored files
--tree-in specify input as syntax tree
--tree-out output syntax tree
--inspect output formatted syntax tree
--[no-]stdout specify writing to stdout (on by default)
--[no-]color specify color in report (on by default)
--[no-]config search for configuration files (on by default)
--[no-]ignore search for ignore files (on by default)
Examples:
# Process `input.md`
$ remark input.md -o output.md
# Pipe
$ remark < input.md > output.md
# Rewrite all applicable files
$ remark . -o
```
API
remark.use(cliHelp[, options])
Adds the output from node ./cli.js --help
to the cli
section in a readme.md
.
Removes the current content between the heading containing the text “cli”, and the next heading of the same (or higher) depth, and replaces it with the help output.
options
options.cwd
string?
— Path to a directory containing a node module. Used to infer name
,
main
, and bin
.
options.name
string?
— Name of the command, inferred from package.json
s name
property.
Used to write the help command output $ some-command --help
.
options.bin
string?
— Path to the cli script. Resolved from package.json
s bin
property (or cli.js
). See the npm documentation
for more details
options.args
Array<string>?
— Arguments used to run the help command. Defaults to ['--help']
options.heading
string?
, default: 'cli'
— Heading to look for, wrapped in
new RegExp('^(' + value + ')$', 'i');
.
Contribute
See contributing.md
in remarkjs/remark
for ways to get
started.
This organisation has a Code of Conduct. By interacting with this repository, organisation, or community you agree to abide by its terms.