# node-prompt

> A customizable command prompt for node applications, locally or over the net.

Latest version **0.2.2** (published 2016-08-18) · MIT license · 0 weekly downloads

## Install

```sh
npm install node-prompt
pnpm add node-prompt
yarn add node-prompt
bun add node-prompt
```

Provides the command `node-prompt`.

## 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.2.2 |
| Published | 2016-08-18 |
| First published | 2016-08-18 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 4 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Joshua Wise |
| Maintainers | joshuawise |
| Keywords | command, terminal, application, ipc, ssh |

## Links

- npm: https://www.npmjs.com/package/node-prompt
- Repository: https://github.com/JoshuaWise/node-prompt
- Homepage: https://github.com/JoshuaWise/node-prompt#readme
- Issues: https://github.com/JoshuaWise/node-prompt/issues
- npm.io page: https://npm.io/package/node-prompt

## Dependencies (4)

- [yargs](https://npm.io/package/yargs.md) ^5.0.0
- [bluebird](https://npm.io/package/bluebird.md) ^3.4.1
- [cli-color](https://npm.io/package/cli-color.md) ^1.1.0
- [is-promise](https://npm.io/package/is-promise.md) ^2.1.0

## Alternatives

- [@salesforce/cli](https://npm.io/package/@salesforce/cli.md) — 389.7K weekly downloads
- [@mintlify/cli](https://npm.io/package/@mintlify/cli.md) — 208.9K weekly downloads
- [@grafana/e2e-selectors](https://npm.io/package/@grafana/e2e-selectors.md) — 128.7K weekly downloads
- [mintlify](https://npm.io/package/mintlify.md) — 112.0K weekly downloads
- [@intlayer/cli](https://npm.io/package/@intlayer/cli.md) — 22.8K weekly downloads

## Recent versions

- 0.2.2 (latest) — 2016-08-18
- 0.2.1 — 2016-08-18
- 0.2.0 — 2016-08-18

## README

# node-prompt
`node-prompt` lets you control a node application directly from another computer, using a REPL interface.

## Usage
##### Getting started
```js
var prompt = require('node-prompt').stdin({prompt: '> '}); // Read from stdin

// *** OR ***

var prompt = require('node-prompt').net({ // Read from a network connection
    prompt: '> ',
    port: 43210,
    allowMultipleClients: false
});

// The above options are the defaults
```

##### Set up some commands
```js
prompt.command('getCurrentClients', function () {...});
prompt.command('doMyCustomAction', function () {...});
prompt.command('getUsageCPU', function () {...});
```

##### Or multiple commands at once
```js
prompt.command({
	getCurrentClients: function () {...},
	doMyCustomAction: function () {...},
	getUsageCPU: function () {...}
});
```

## Access the application
You can execute commands remotely by using the `node-prompt` CLI tool.

First, install the CLI tool:
```
sudo npm install -g node-prompt
```

Then connect to your node application, and start typing commands!
```
node-prompt myapplication.com:9000
> getUsageCPU
CPU usage at 2%
> doMyCustomAction 45 "this is a single argument"
You did a custom action with 2 arguments!
```

## Synchronous and asynchronous return values
For synchronous commands, you can send back a response message by returning a string. If an error is thrown, that error message will be sent back as the response, instead.

You can only send response messages that are strings. If any other type of data is returned, an empty string is used instead.

There are two ways to have asynchronous commands...

#### Callbacks
If the first argument of the handler is named `$callback`, a node-style callback function will be passed as that argument. All other arguments will come after.

```js
prompt.command('getUsername', function ($callback, emailAddress) {
    getUsername(emailAddress, $callback);
});
```

#### Promises
If the handler returns a promise (or promise-like object), its fulfillment value or rejection reason will be used as the response message.

```js
prompt.command('getUsername', function (emailAddress) {
    return getUsername(emailAddress);
});
```

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