New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

mtd-help

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mtd-help

A helpful Track.

  • 1.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
2
decreased by-66.67%
Maintainers
1
Weekly downloads
 
Created
Source

mtd-help

NPM version Downloads

This module provides an easy way to define a help track for applications using mtd.

Install

Using npm.

$ npm install mtd-help

Example

A simple example.

// simple.js
'use strict';

const Depot = require('mtd');
const help = require('mtd-help');

new Depot()

.default('help', [], help(
  { name: 'Help Example',
    hide: false },
  { foo: 'A line about foo.',
    bar: 'A line about bar.',
    help: 'Display this message.' }
))

.track(
  'foo',
  [
    { $: 'zal', alias: 'z', info: 'A description for zal.' },
    { $: 'qux', _: 'hello, world', alias: 'q', info: 'A description for qux.' }
  ],
  (zal, qux) => console.log(zal, qux)
)

.track(
  'bar',
  [ { $: 'baz', alias: 'b', info: 'A description for baz.' } ],
  baz => console.log(baz)
)

.embark();

Running our example application either as $ node simple.js or verbosely as $ node simple.js help will print the following to our terminal, complete with pretty colours.

Help Example

[ Multiple: On ][ Reruns: Off ][ Warnings: On ]

[ bar ] A line about bar.
  --baz, -b  
    A description for baz.

[ foo ] A line about foo.
  --zal, -z  
    A description for zal.
  --qux, -q  (default: hello, world)
    A description for qux.

[ help ] (default) Display this message.

Documentation

Require the module, as you would any other Node module.

const help = require('mtd-help');

help is now a factory function that creates a suitable Track block. It has the following signature.

factory (
    settings: HelpSettings,
    descriptions: GenericObject = {}
): Block

HelpSettings is an interface that looks like:

interface HelpSettings {
    /*
     * The name of your application,
     * displayed at the top of the help print out.
     */
    name: string;

    /*
     * Whether to list the track that is
     * associated with the block generated
     * in the final output.
     */
    hide: boolean;
}

descriptions is a GenericObject:

interface GenericObject extends Object {
    [index: string]: any;
}

Its keys should be strings, corresponding to Track handles in your application. Each value should be a description of the matching track.


Enjoy!

oka.io

Keywords

FAQs

Package last updated on 27 May 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc