# clargs

> An easy way to gather user input for your scripts.

Latest version **0.1.0** (published 2016-01-06) · MIT license · 0 weekly downloads

## Install

```sh
npm install clargs
pnpm add clargs
yarn add clargs
bun add clargs
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.0 |
| Published | 2016-01-06 |
| First published | 2015-07-09 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Ben Bradley |
| Maintainers | ben-bradley |

## Links

- npm: https://www.npmjs.com/package/clargs
- npm.io page: https://npm.io/package/clargs

## Dependencies (2)

- [argify](https://npm.io/package/argify.md) 0.0.3
- [inquirer](https://npm.io/package/inquirer.md) ^0.11.1

## Recent versions

- 0.1.0 (latest) — 2016-01-06
- 0.0.1 — 2015-07-09

## README

# clargs [![Build Status](https://secure.travis-ci.org/ben-bradley/clargs.png)](http://travis-ci.org/ben-bradley/clargs)

I found myself writing a lot of CLI apps that used `argify` to convert command-line args into values that I could use in code.  This worked well, but I was constantly having to crack open the script source to remind myself which args a particular script expected.

I like being prompted to provide arguments, but sometimes I want to just 'up-arrow+enter' a script instead.

To address this, I wrote `clargs` to combine the functionality of `argify` with the super-awesome `inquirer` module.  The idea is that you can provide args at the command-line, and get prompted for the ones you forget

## Use

Using `clargs` is simple.  Because it has the potential to accept user input, I have it return a promise so that you can integrate it cleanly into your app.

`clargs` accepts an array of Inquirer question objects.  The `name` property of each question correlates to the `--` argument specified at run-time.  For example:

```javascript
/**
 * $ node ./myscript.js --foo=bar
 */

 // myscript.js
'use strict';

var clargs = require('clargs');

var questions = [{
  type: 'input',
  name: 'foo', // --foo=bar
  message: 'foo'
}, {
  type: 'confirm',
  name: 'baz', // there was no --baz so this question is asked
  message: 'baz?',
  default: true
}];

clargs(questions)
	.then(function(args) {
		console.log('Args:', args);
    /**
     * { foo: 'bar', baz: true }
     */
	});
```

## Versions

- 0.1.0 - Removed `q` dependency, updated deps
- 0.0.1 - Initial commit

---
_Source: https://npm.io/package/clargs · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
