# terminal-menu-disabler

> A package that extends terminal-menu, making it capable of enabling/disabling menu items on the fly.

Latest version **0.1.3** (published 2016-04-25) · MIT license · 0 weekly downloads

## Install

```sh
npm install terminal-menu-disabler
pnpm add terminal-menu-disabler
yarn add terminal-menu-disabler
bun add terminal-menu-disabler
```

## 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.3 |
| Published | 2016-04-25 |
| First published | 2015-01-05 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Sampath Sitinamaluwa |
| Maintainers | sampathsris |
| Keywords | menu, terminal, ansi, enable, disable |

## Links

- npm: https://www.npmjs.com/package/terminal-menu-disabler
- Repository: https://github.com/sampathsris/terminal-menu-disabler
- Issues: https://github.com/sampathsris/terminal-menu-disabler/issues
- npm.io page: https://npm.io/package/terminal-menu-disabler

## Alternatives

- [localforage](https://npm.io/package/localforage.md) — 6.2M weekly downloads
- [localforage-observable](https://npm.io/package/localforage-observable.md) — 30.8K weekly downloads
- [@y/y](https://npm.io/package/@y/y.md) — 30.1K weekly downloads
- [@metaobjectsdev/render](https://npm.io/package/@metaobjectsdev/render.md) — 3.5K weekly downloads
- [@ledgerhq/coin-algorand](https://npm.io/package/@ledgerhq/coin-algorand.md) — 1.1K weekly downloads

## Recent versions

- 0.1.3 (latest) — 2016-04-25
- 0.1.2 — 2015-01-07
- 0.1.1 — 2015-01-05
- 0.1.0 — 2015-01-05

## README

#terminal-menu-disabler

A package that extends [terminal-menu](https://www.npmjs.com/package/terminal-menu), making it capable of enabling/disabling menu items on the fly.

#example

```
var menu = require('terminal-menu')({ width: 30, x: 2, y: 2 });
var disabler = require('terminal-menu-disabler')(menu, {
  // uncomment following line to make forground
  // color of disabled menu items red
  // fgi: 'red',
  disabled: [
    // you can have a list of labels to be disabled
    // at startup here.
  ]
});

var sd = 'Self Distruct',
    esd = 'Enable \'Self Distruct\' (!)';

menu.reset();
menu.write('MARVIN\'S TODO LIST\n');
menu.write('-----------------------------\n');

menu.add('Complain');
menu.add('Whine');
menu.add('Do Nothing');
menu.add(sd);

menu.write('-----------------------------\n');
menu.add(esd);
menu.add('EXIT');

menu.on('select', function (label) {
  if (label === esd) {
    menu.enableMenu(sd);
    menu.disableMenu(esd);
  } else {
    menu.close();
    console.log('Marvin will ' + label.toLowerCase() + ' now!');
  }
});
menu.createStream().pipe(process.stdout);
menu.disableMenu(sd);
```

#usage

```
var disabler = require('terminal-menu-disabler')
disabler(menu, opts);
```

- `menu` is an instance of a terminal menu created with [terminal-menu](https://www.npmjs.com/package/terminal-menu)
- `opts` is an object, which may have following properties
    - `opts.fgi`: Foreground color for inactive menu items. This also becomes the background color for inactive menu items when it is selected.
    - `opts.disabled`: An array of string literals indicating the menu items to be disabled on startup.
    
After calling `disabler(menu, opts)`, two functions will be injected to `menu`, which you can use to enable/disable individual menu items.

- `menu.enableMenuItem(item)`
- `menu.disableMenuItem(item)`

`item` can be a label (string) or a zero based index (number) of a menu item.
    
#installation

```
npm install terminal-menu-disabler
```

#licence

MIT

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