Skip to content

How to add a command list to your usage guide

Lloyd Brookes edited this page Jun 30, 2019 · 1 revision

Useful if your app is command-driven, like git or npm.

Code

const commandLineUsage = require('command-line-usage')

const sections = [
  {
    header: 'Example App',
    content: 'Generates something {italic very} important. This is a rather long, but ultimately inconsequential description intended solely to demonstrate description appearance. '
  },
  {
    header: 'Synopsis',
    content: '$ app <options> <command>'
  },
  {
    header: 'Command List',
    content: [
      { name: 'help', summary: 'Display help information about Git.' },
      { name: 'commit', summary: 'Record changes to the repository.' },
      { name: 'Version', summary: 'Print the version.' },
      { name: 'etc', summary: 'Etc.' }
    ]
  }
]

const usage = commandLineUsage(sections)
console.log(usage)

Output

usage