Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 400,000 packages pre-installed, including usually with all npm packages installed. Try it out:

var usually = require("usually")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

usually v1.2.0

Prints Usage For Node.JS Command-Line Applications.

usually

npm version

Usually Will Generate Usage Of Node.JS Command-Line Applications. It is compatible with Argufy which can save arguments in the arguments.xml file, and extract them with auto-generated JavaScript compatible with Google Closure Compiler.

yarn add -E usually

Table Of Contents

API

The package is available by importing its default function:

import usually from 'usually'

The types and externs for Google Closure Compiler via Depack are defined in the _usually namespace.

usually(
  config: Config,
): string

Create a string to display as a help message.

___usually.Config__: The configuration object.

NameTypeDescription
usage*!Object<string, string>The map with possible arguments (flags, options) and their information.
descriptionstringWhat does the program do?
linestringThe summary of the program in one line.
examplestringThe example of the program usage.
import usually from 'usually'

const res = usually({
  usage: {
    '-h': 'print help',
    '-c': 'execute this command',
  },
  description: 'A test command-line application',
  line: 'usually [-c command|command2] [-h]',
  example: 'usually -c command2',
})

console.log(res)
A test command-line application

  usually [-c command|command2] [-h]

    -h  print help
    -c  execute this command

  Example:

    usually -c command2

The algorithm will tab the usage object and all new lines will appear indented to the required padding.

import usually from 'usually'

const res = usually({
  usage: {
    '-h': 'print help',
    '-c': `execute this command, that will perform
the operations on the CPU and return result
upon the full execution or terminate after
30s of inactivity.`,
  },
  description: 'Run the usually',
})
Run the usually

    -h  print help
    -c  execute this command, that will perform
        the operations on the CPU and return result
        upon the full execution or terminate after
        30s of inactivity.

Argufy Integration

Argufy is a program that manages arguments for CLI programs by storing them in a separate XML file so that they are readily updatable in both source code and README documentation. It also generates the script that extracts those arguments and works with Google Closure Compiler. Read More.

Copyright

(c) Art Deco 2019

RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free