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 applause-cli with all npm packages installed. Try it out:

var applauseCli = require("applause-cli")

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

applause-cli v1.2.4

Super-duper lightweight no-dependency alternative to clap


Super-duper lightweight no-dependency alternative to clap

Inspired by clap. It wasn't quite what I wanted, so I wrote my own :P

This is refactored out of my main PhDcodebase, so if you're wondering why there aren't very many commits, that's why.

  • Current version: current npm version - see the GitHub releases
  • API Docs:
  • Changelog:


Install via npm:

npm install applause-cli --save


Example usage:

"use strict";

import CliParser from 'applause-cli';

// HACK: Make sure __dirname is defined when using es6 modules. I forget where I found this - a PR with a source URL would be great :D
const __dirname = import.meta.url.slice(7, import.meta.url.lastIndexOf("/"));

// Locate your package.json - this assumes it's sitting in the same directory as this file
const package_json_filepath = path.resolve(__dirname, "../package.json");

// Create a new CLI parser
// The name description, version number, etc are all populated from there
const cli = new CliParser(package_json_filepath);

cli.argument("foo", "This is a global argument.", true, "boolean")

cli.subcommand("do_stuff", "Do some stuff.")
    // An argument just for this subcommand
    .argument("input", "The input file to do stuff with.", "default_value_here", "string");


The full API documentation can be found here: (TODO: Insert a link here)

Argument Types

Several argument types are currently supported. They are specified as the 4th argument to the .argument() command (either globally or on a specific subcommand):

stringJust a string.
integerAn integer (parseInt(value, 10) is used)
floatA floating-point number (parseFloat(value) is used)
booleanA boolean true/false value. Unlike other types, arguments with this type do not take an explicit value on the cli (e.g. --foo bar) - rather their presence on the CLI sets the value to true. This can be overridden though with argument.has_value = true.

In addition, a function can be passed instead of a string defining the type of an argument, and that function will be called with a single argument to parse values instead:

// .....
cli.argument("foo", "An example argument --foo", 128, function(value) {
    // Parse the value as an int and double it before returning
    return parseInt(value, 10) * 2;

Read-world use

  • I'm using it for the main Node.js application for my PhD in Computer Science!
  • (Are you using this project? Get in touch by opening an issue)


Contributions are welcome as PRs! Don't forget to say that you donate your contribution under the Mozilla Public License 2.0 in your PR comment.


This project is licensed under the Mozilla Public License 2.0. See the LICENSE file in this repository for the full text.

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