Skip to content

Latest commit

 

History

History
52 lines (38 loc) · 1.76 KB

README.md

File metadata and controls

52 lines (38 loc) · 1.76 KB

Node Peco

peco nodejs binding library

NOTE: external command peco is required. see peco installation

NPM github ci npm npm bundle size

example

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:

key type description default
bin string peco 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