@mitsuru793/commander-document-generator
This generates document for tj/commander.js. It helps you to write sections of command guide on README.md.
Last updated a year ago by mitsuru793 .
MIT · Original npm · Tarball · package.json
$ cnpm install @mitsuru793/commander-document-generator 
SYNC missed versions from official npm registry.

Commander Document Generator

This generates document for tj/commander.js. It helps you to write sections of command guide on README.md.

Installation

$ yarn add commander-document-generator

Write template

You must write a template for a command with janl/mustache.js.

You can use a variable 'command' in template. The following is property list of 'command'.

Command

  • name: string
  • args: Argument[]
  • options: Option[]
  • description: string

Argument

  • name: string
  • display: boolean
  • required: boolean
  • variadic: boolean

Option

  • flags: string
  • required: boolean
  • optional: boolean
  • bool: boolean
  • short?: string
  • long: string
  • description: string

Example

import {Command as Commander} from "commander"
import CommandDocument from "commander-document-genertor"

const program = new Commander()

program
  .command('hello <message>')
  .description('just hello')
  .option("-t, --to <name>", "target user")
  .option("-s, --silent", "not say")

const template = `
{{#commands}}
### {{name}} {{{args.0.display}}}

{{description}}

{{#options}}
#### {{{flags}}}

{{description}}
{{/options}}
{{/commands}}
`

const doc = CommandDocument.parse(program)
console.log(doc.render(template))

output

### hello <message>

just hello

#### -t, --to <name>

target user

#### -s, --silent

not say

Current Tags

  • 0.1.2                                ...           latest (a year ago)

2 Versions

  • 0.1.2                                ...           a year ago
  • 0.1.0                                ...           a year ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (2)
Dev Dependencies (9)
Dependents (0)
None

Copyright 2014 - 2016 © taobao.org |