项目作者: linterhub

项目描述 :
Usage parser
高级语言: TypeScript
项目地址: git://github.com/linterhub/usage-parser.git
创建时间: 2018-06-26T17:03:08Z
项目社区:https://github.com/linterhub/usage-parser

开源协议:MIT License

下载


@linterhub/usage-parser travis semantic @linterhub/usage-parser"">npm github

Simple parser for usage page in CLI

Table of Contents

Background

There are a lot of CLI with different usage doc, distributed in different ways.
This repository contains a proposal to unified format for arguments
of various CLI. Under the hood, the main idea is pretty similar
to docopt approach.

More details in doс or at the catalog page

Install

  1. npm install @linterhub/usage-parser

GitHub

All releases and the source code are available for download
at GitHub Releases.

Usage

Parse help doc and output result to console:

JavaScript

  1. const usageParser = require('@linterhub/usage-parser');
  2. const usage = new UsageParser('Help doc from CLI');
  3. console.log(usage.parse());
  1. import UsageParser from '@linterhub/usage-parser';
  2. const usage = new UsageParser('Help doc from CLI');
  3. console.log(usage.parse());

CLI

  1. Usage: bin [options] <binary>
  2. Parse help page specifying binary as argument or content as option
  3. Options:
  4. -V, --version output the version number
  5. -d, --docs <docs> The help page content (pass without <binary> argument)
  6. -f, --file <file> Path to a file with CLI docs
  7. -h, --help output usage information
  8. Examples:
  9. $ usage-parser mocha // Parser runs help command for `mocha` and parse output
  10. $ usage-parser eslint // Parser runs help command for `eslint` and parse output
  11. $ usage-parser --file "usage-file.txt"
  12. $ usage-parser --docs "usage text"

Contribute

You may contribute in several ways like requesting new features,
adding tests, fixing bugs, improving documentation or examples.
Please check our contributing guidelines.

License

MIT