TypeScript icon, indicating that this package has built-in type declarations

0.1.2 • Public • Published


Simple and well written command line applications helper

NPM version Build Status Coverage percentage Project License

What is clito?

Clito, pronounced as in "clitoris", stands for cli-tools and it's a well written command line application helper. It will become your best friend when dealing with cli applications, once you start play with it you will like it more than any other tool. 😏


Oops.. move along children, you are holding up the line, let see some features now..


  • Parses arguments respecting types
  • Boolean defaults to false
  • Support required options
  • Support multiple option arguments
  • Support for option value validation
  • Negates flags when using the --no- prefix
  • Outputs version when --version
  • Build help string from options when called with --help
  • Customizable help usage and command examples

Getting started

Install the module using your favourite package manager:

npm install clito

Load it in your application code and set it up:

#!/usr/bin/env node
const clito = require('clito');
const cli = clito({
  usage: 'askme <question>',
  flags: {
    person: {
      type: 'string',
      alias: 'p',
      default: 'chef'
  examples: [
    'askme -p "ghandi" "Do you ever got angry?"'
const {input, flags} = cli
const [question] = input
if (!question || question === '') {
  console.error('You must ask a question first!');
if (flags.person === 'chef') {
  console.log('> You gotta find the clitoris children.');
} else {
  // evaluate question and answer it

Than run it with some input and options:

$ node ./index.js "How do you make a girl love you more than other people?"
> You gotta find the clitoris children.


The module can accept various options to customize the behavior or help string output.


Type: Object
Required: true

An object of name paired flags that are going to be used as command options and parsed.

A flag itself it's an object than can take various properties to describe how the flag should be parsed and outputted in help message:

  • type: The flag type that should be returned from parsing (this field is required)
  • alias: An alias for the flag (dashes are added automatically)
  • description: The flag description used in the help message
  • default: The flag default value in case not specified
  • required: Identify the flag as required, will throw an error if flag is missing
  • multiple: specify that the flag accept multiple arguments and should be parsed as array

Example flag:

  foo: {
    type: 'string',
    alias: 'f',
    description: 'A foo option',
    default: 'bar',
    validation: (v) => true,
    required: false,
    multiple: false


Type: String

Add a custom banner string to be printed on top of --help message.


Type: String
Default: $ {} <input>

Set a custom usage string to be used in --help message.


Type: String, String[]

Add custom command usage examples to be appended on bottom of --help message.


Type: Number
Default: 0

Set the indentation size used in the built-in help message.


Type: Boolean
Default: true

Shows the command version when called with --version.


Type: Boolean
Default: true

Shows the built-in command help when called with --help.


This package is under MIT license and its made with love by Filippo Conti

Package Sidebar


Weekly Downloads






Unpacked Size

14.4 kB

Total Files


Last publish


  • b4dnewz