GithubHelp home page GithubHelp logo

cli-usage's Introduction

cli-usage

Easily show the usage of your CLI tool from a Markdown string or file. You can just plug cli-usage in without thinking about paramters, or you can handle that your self using the .get API end-point.

Install

npm install cli-usage

Usage

Most basic usage, just plug in:

var usage = require('cli-usage');
usage();
//=> If help-flag is passed, print usage
//=> and exit with code 0.

This will listen for -h, -help or --help passed into your CLI and try to locate a usage.md file from the directory of the file. If help is passed and the usage.md file found, the usage will be printed and the application will exit with code 0.

You can also pass in a filename or a string.

var usage = require('cli-usage');
usage('./some/path/to/usage.md');

or

var usage = require('cli-usage');
usage('# Simple usage');

Get compiled usage

Instead of cli-usage doing all the work, you can also just retrieve the compiled usage text and handle it your self.

Example

var usage = require('cli-usage');

console.log(usage.get('# some custom markdown from string'));

console.log(usage.get('./usage.md'));

cli-usage's People

Contributors

apoco avatar cpojer avatar gfx avatar mikaelbr avatar sectsect avatar turbo87 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

cli-usage's Issues

marked-terminal version 3.2.0 is not yet posted to npm?

npm ERR! code ETARGET
npm ERR! notarget No matching version found for marked-terminal@^3.2.0
npm ERR! notarget In most cases you or one of your dependencies are requesting
npm ERR! notarget a package version that doesn't exist.
npm ERR! notarget
npm ERR! notarget It was specified as a dependency of 'cli-usage'
npm ERR! notarget

[email protected] throwing 'undefined is not a function'

Between marked 0.3.3 and 0.3.5, mversion -h started throwing an error:

$ mversion -h
/usr/local/lib/node_modules/mversion/node_modules/cli-usage/node_modules/marked/lib/marked.js:1226
    throw e;
          ^
TypeError: undefined is not a function
Please report this to https://github.com/chjj/marked.
    at InlineLexer.output (/usr/local/lib/node_modules/mversion/node_modules/cli-usage/node_modules/marked/lib/marked.js:685:28)
    at Parser.tok (/usr/local/lib/node_modules/mversion/node_modules/cli-usage/node_modules/marked/lib/marked.js:985:21)
    at Parser.parse (/usr/local/lib/node_modules/mversion/node_modules/cli-usage/node_modules/marked/lib/marked.js:935:17)
    at Function.Parser.parse (/usr/local/lib/node_modules/mversion/node_modules/cli-usage/node_modules/marked/lib/marked.js:922:17)
    at marked (/usr/local/lib/node_modules/mversion/node_modules/cli-usage/node_modules/marked/lib/marked.js:1218:19)
    at fromFile (/usr/local/lib/node_modules/mversion/node_modules/cli-usage/index.js:45:10)
    at get (/usr/local/lib/node_modules/mversion/node_modules/cli-usage/index.js:30:12)
    at module.exports (/usr/local/lib/node_modules/mversion/node_modules/cli-usage/index.js:22:15)
    at Object.<anonymous> (/usr/local/lib/node_modules/mversion/bin/cli.js:9:1)
    at Module._compile (module.js:460:26)

Manually rolling back marked to 0.3.3 solves the problem. Sorry, I'm kind of lazy to dig any deeper =)

Installation of cli-usage failing on dependency marked-terminal

Error:

npm ERR! node v4.2.1
npm ERR! npm  v2.15.9
npm ERR! code ETARGET

npm ERR! notarget No compatible version found: marked-terminal@'>=1.6.2 <2.0.0'
npm ERR! notarget Valid install targets:
npm ERR! notarget ["0.1.0","1.0.0","1.1.0","1.1.1","1.1.2","1.1.3","1.2.0","1.3.0","1.4.0","1.5.0","1.6.0","1.6.1"]

Update Dependency Package

Thanks for useful package.

I got the following warning on GitHub.

โš ๏ธ We found potential security vulnerabilities in your dependencies.
Some of the dependencies defined in your package-lock.json have known security vulnerabilities and should be updated.

capture 2018-01-06 at 12 32 13

I think that it is necessary to update the "marked" package.

@via markedjs/marked#997

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.