0.1.6 • Published 3 years ago

node-peco v0.1.6

Weekly downloads
8
License
MIT
Repository
github
Last release
3 years ago

Node Peco

peco nodejs binding library

NOTE: external command peco is required. see peco installation

NPM github ci npm npm bundle size

Installation

yarn add node-peco

Usage

This package exports only one function named peco.

import { peco } from 'node-peco'; // or require('node-peco');

peco(['foo', 'bar', 'baz']).then(selected => console.log(selected));

You can pass option as a second argument

import { peco, PecoOption } from 'node-peco';

const pecoOption: PecoOption = {
  onCancel: 'reject',
  layout: 'bottom-up',
  selectionPrefix: '*',
  prompt: "Choose ->",
};

peco(['foo', 'bar', 'baz'], pecoOption).then(selected => console.log(selected));

for more examples, see examples

Option

There are two categories of option. One is js dependent:

keytypedescriptiondefault
binstringpeco binary command(or location path)"peco"
onCancel"reject" \| "skip"specify behavior when received SIGINT"skip"
onError"reject" \| "exit"specify behavior when peco exited with non-zero code"exit"

The other is peco command line option. See peco#command-line-options