clapp
A tool for building command line apps that don't aren't necessarily built for the command line.
Last updated 6 months ago by mellamopablo .
Apache-2.0 · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install clapp 
SYNC missed versions from official npm registry.

clapp NPM version Build Status Dependency Status Coverage percentage

A tool for building command line apps that aren't necessarily built for the command line.

Average time to resolve an issue Percentage of issues still open PRs Welcome

Installation

$ npm install --save clapp

Features

  • Input isn't restricted to node's process.argv, unlike other libraries, so you may use Clapp for a node cli app, or use it for anything alse. For instance, you may use it for a discord bot, where an user message is the input, and the bot behaves like a command line app.
  • Clapp also handles command execution. When using other command parsing libraries, you'd need to manually execute the command function by evaluating the user input. Clapp will execute the command for you if the user input satisfies your needs, or let the user know the error otherwise.
  • Clapp allows you to have precise control of user input: it takes care of required arguments, default values, data types, and data validation for you.
  • It also handles documentation. Clapp takes an "if you don't document it, go fuck yourself" apporach, meaning that it will simply not work if you don't document your app. For example, if you don't declare an argument that you expect the user to pass, Clapp will ignore it and not pass it back to you. But because of that, Clapp is able to easily print documentation to the user when they pass the --help flag.
  • Clapp handles the --version flag as well.

Usage

const Clapp = require('clapp');

let app = new Clapp.App({
	name: "Test App",
	desc: "An app that does the thing",
	prefix: "-testapp",
	version: "1.0",
	onReply: function(msg, context) {
		// Clapp will use this function to
		// communicate with the end user
		console.log(msg);
	}
});

app.addCommand(new Clapp.Command({
	name: "foo",
	desc: "An example command",
	fn: function(argv, context) {
		return "Foo was executed!"
	}
}));

let userInput = "-testapp foo";

// Checks if the user input is an acceptable command
if (app.isCliSentence(userInput)) {
	app.parseInput(userInput); // logs "Foo was executed!"
}

Please check out the docs for the full instructions!

License

Apache-2.0 © Pablo Rodríguez

Current Tags

  • 1.3.3                                ...           latest (6 months ago)

19 Versions

  • 1.3.3                                ...           6 months ago
  • 1.3.2                                ...           a year ago
  • 1.3.1                                ...           2 years ago
  • 1.3.0                                ...           2 years ago
  • 1.2.1                                ...           3 years ago
  • 1.2.0                                ...           3 years ago
  • 1.1.1                                ...           3 years ago
  • 1.1.0                                ...           3 years ago
  • 1.0.1                                ...           3 years ago
  • 1.0.0                                ...           3 years ago
  • 0.2.0                                ...           3 years ago
  • 0.1.7                                ...           3 years ago
  • 0.1.6                                ...           3 years ago
  • 0.1.5                                ...           3 years ago
  • 0.1.4                                ...           3 years ago
  • 0.1.3                                ...           3 years ago
  • 0.1.2                                ...           3 years ago
  • 0.1.1                                ...           3 years ago
  • 0.1.0                                ...           3 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 19
Last Day 0
Last Week 0
Last Month 19
Dependencies (2)
Dev Dependencies (22)

Copyright 2014 - 2016 © taobao.org |