# resin-cli-form

> Resin.io CLI form interpreter

Latest version **5.0.1** (published 2026-02-23) · Apache-2.0 license · 0 weekly downloads

## Install

```sh
npm install resin-cli-form
pnpm add resin-cli-form
yarn add resin-cli-form
bun add resin-cli-form
```

## Health

**Score 60/100 (C)** — status: stable.

Positive: has types; no vulnerabilities; has provenance; high quality score.

Warnings: low downloads; no esm support.

## Facts

| | |
|---|---|
| Version | 5.0.1 |
| Published | 2026-02-23 |
| First published | 2015-06-25 |
| Weekly downloads | 0 |
| License | Apache-2.0 |
| TypeScript types | bundled |
| Module format | CommonJS |
| Node | >=20.0 |
| Dependencies | 4 |
| Unpacked size | 44.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Provenance | attested (GitHub Actions) |
| GitHub stars | 1 |
| Author | Juan Cruz Viotti |
| Maintainers | balena.io |
| Keywords | resin, form, cli |

## Links

- npm: https://www.npmjs.com/package/resin-cli-form
- Repository: https://github.com/balena-io-modules/resin-cli-form
- Issues: https://github.com/balena-io-modules/resin-cli-form/issues
- npm.io page: https://npm.io/package/resin-cli-form

## Dependencies (4)

- [tslib](https://npm.io/package/tslib.md) ^2.8.1
- [lodash](https://npm.io/package/lodash.md) ^4.17.21
- [inquirer](https://npm.io/package/inquirer.md) ^7.0.6
- [resin-cli-visuals](https://npm.io/package/resin-cli-visuals.md) ^4.0.1

## Alternatives

- [mobx-react](https://npm.io/package/mobx-react.md) — 2.8M weekly downloads
- [rc-tree](https://npm.io/package/rc-tree.md) — 2.6M weekly downloads
- [@react-oauth/google](https://npm.io/package/@react-oauth/google.md) — 1.3M weekly downloads
- [@wagmi/connectors](https://npm.io/package/@wagmi/connectors.md) — 877.0K weekly downloads
- [vee-validate](https://npm.io/package/vee-validate.md) — 836.4K weekly downloads

## Recent versions

- 5.0.1 (latest) — 2026-02-23
- 5.0.1-build-add-npm-oidc-permissions-fe2e065115b2798d36c31a358299787008189890-1 (build-add-npm-oidc-permissions) — 2026-02-23
- 5.0.0-build-convert-to-ts-9a9cfb5480ef87b570596b3f6fc2858d73e2600f-1 (build-convert-to-ts) — 2025-09-19
- 4.0.2-build-ts-tests-0241d239bcc073259c62ab8f526186cf590831bd-1 (build-ts-tests) — 2025-09-18
- 4.0.1-build-bump-resin-cli-visuals-22a7da6add65372b1810811e347a515d81e05bd9-1 (build-bump-resin-cli-visuals) — 2025-09-16
- 4.0.0-build-drop-node18-290678632f404da0a842569bed69db7c1fa8515d-1 (build-drop-node18) — 2025-06-06
- 3.0.0-build-etcher-sdk-9-d7b4e5463e0c2cea03294c498dd90f8a02f3259d-1 (build-etcher-sdk-9) — 2024-04-08
- 5.0.0 — 2025-09-21
- 4.0.2 — 2025-09-19
- 5.0.0-build-convert-to-ts-90fd88922ddf042925ffd2bd209933137c1e7fd0-1 — 2025-09-18
- 5.0.0-build-convert-to-ts-8af5fd6a38dba97316f68e49eb01ca0770dcc9d3-1 — 2025-09-18
- 5.0.0-build-convert-to-ts-ee50c0f7ced160ae9767ac024d50837c63314594-1 — 2025-09-18
- 5.0.0-build-convert-to-ts-4c74d2387c896b8f29fc26adbf5e53123745d08d-1 — 2025-09-18
- 5.0.0-build-convert-to-ts-e4e672b3ebc3942b5fd96d64d124b46690519434-1 — 2025-09-18
- 4.0.2-build-ts-tests-e679aa03a617c4ede4fd30b480d5ac24a01a6c64-1 — 2025-09-18
- … 27 more at https://npm.io/package/resin-cli-form/versions

## README

resin-cli-form
--------------

[![npm version](https://badge.fury.io/js/resin-cli-form.svg)](http://badge.fury.io/js/resin-cli-form)
[![dependencies](https://david-dm.org/resin-io-modules/resin-cli-form.png)](https://david-dm.org/resin-io-modules/resin-cli-form.png)
[![Build Status](https://travis-ci.org/resin-io-modules/resin-cli-form.svg?branch=master)](https://travis-ci.org/resin-io-modules/resin-cli-form)
[![Build status](https://ci.appveyor.com/api/projects/status/hmvcyjfwbxqd1wru/branch/master?svg=true)](https://ci.appveyor.com/project/resin-io/resin-cli-form/branch/master)

Join our online chat at [![Gitter chat](https://badges.gitter.im/resin-io/chat.png)](https://gitter.im/resin-io/chat)

Resin.io CLI form interpreter.

Role
----

The intention of this module is to provide an interpreter for our internal declarative form definitions.

Installation
------------

Install `resin-cli-form` by running:

```sh
$ npm install --save resin-cli-form
```

Documentation
-------------


* [form](#module_form)
  * [.run(form, [options])](#module_form.run) ⇒ <code>Promise.&lt;Object&gt;</code>
  * [.ask(question)](#module_form.ask) ⇒ <code>Promise.&lt;\*&gt;</code>

<a name="module_form.run"></a>
### form.run(form, [options]) ⇒ <code>Promise.&lt;Object&gt;</code>
**Kind**: static method of <code>[form](#module_form)</code>  
**Summary**: Run a form description  
**Returns**: <code>Promise.&lt;Object&gt;</code> - answers  
**Access:** public  

| Param | Type | Default | Description |
| --- | --- | --- | --- |
| form | <code>Array.&lt;Object&gt;</code> |  | form description |
| [options] | <code>Object</code> | <code>{}</code> | options |
| [options.override] | <code>Object</code> |  | overrides |

**Example**  
```js
form.run [
	message: 'Processor'
	name: 'processorType'
	type: 'list'
	choices: [ 'Z7010', 'Z7020' ]
,
	message: 'Coprocessor cores'
	name: 'coprocessorCore'
	type: 'list'
	choices: [ '16', '64' ]
],

	# coprocessorCore will always be 64
	# Notice that the question will not be asked at all
	override:
		coprocessorCore: '64'

.then (answers) ->
	console.log(answers)
```
<a name="module_form.ask"></a>
### form.ask(question) ⇒ <code>Promise.&lt;\*&gt;</code>
**Kind**: static method of <code>[form](#module_form)</code>  
**Summary**: Run a single form question  
**Returns**: <code>Promise.&lt;\*&gt;</code> - answer  
**Access:** public  

| Param | Type | Description |
| --- | --- | --- |
| question | <code>Object</code> | form question |

**Example**  
```js
form.ask
	message: 'Processor'
	type: 'list'
	choices: [ 'Z7010', 'Z7020' ]
.then (processor) ->
	console.log(processor)
```

When
----

We use a `when` property to determine the conditions needed for a question to be asked. This property consists of an object determining the value name (as key), and the value it must have (as value) for the condition to hold. A `when` property can depend on one or more answers, by having many key value pairs.

Example:

```coffee
form.run [
	message: 'Network Type'
	name: 'network'
	type: 'list'
	choices: [ 'ethernet', 'wifi' ]
,
	message: 'Wifi Ssid'
	name: 'wifiSsid'
	type: 'input'
	when:
		network: 'wifi'
,
	message: 'Wifi Key'
	name: 'wifiKey'
	type: 'input'
	when:
		network: 'wifi'
]
```

In this case, the wifi ssid and wiki key will only be asked if the network type is `wifi`.

Support
-------

If you're having any problem, please [raise an issue](https://github.com/resin-io-modules/resin-cli-form/issues/new) on GitHub and the Resin.io team will be happy to help.

Tests
-----

Run the test suite by doing:

```sh
$ gulp test
```

Contribute
----------

- Issue Tracker: [github.com/resin-io-modules/resin-cli-form/issues](https://github.com/resin-io-modules/resin-cli-form/issues)
- Source Code: [github.com/resin-io-modules/resin-cli-form](https://github.com/resin-io-modules/resin-cli-form)

Before submitting a PR, please make sure that you include tests, and that [coffeelint](http://www.coffeelint.org/) runs without any warning:

```sh
$ gulp lint
```

License
-------

The project is licensed under the Apache 2.0 license.

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