1.2.0 • Published 5 years ago

@msg-labs/cli-prompt-list v1.2.0

Weekly downloads
1
License
WTFNMFPL-1.0
Repository
github
Last release
5 years ago

cli-prompt-list

Installation

npm install --save @msg-labs/cli-prompt-list

Usage

Default functionality:

const promptForRepo = require( '@msg-labs/cli-prompt-list' );

const repos = [
  'aredridel/node-bin-gen',
  'axios/axios',
  'bitinn/node-fetch',
  'browserify/resolve',
  'chaijs/chai',
  'DefinitelyTyped/DefinitelyTyped',
  'isaacs/rimraf'
];

promptForRepo( repos )
    .then( response => console.dir( response ) );

For all the available options, see the API section.

API

type InteractiveList<T> = (
    candidates: Array<T>,
    prompt?: string,
    renderLine?: (
        candidate?: T,
        index?: number,
        candidates?: Array<T>,
        search?: string
    ) => string,
    searchOptions?: {
        input?: string,
        matchField?: (candidate: T) => any,
        compareFunction?: (
            a?: T,
            b?: T
        ) => boolean,
        limit?: number,
        sortCandidates?: boolean
    }
) => Promise<T>;
ParameterTypeDefaultDescription
candidatesArrayundefinedList of elements to search
promptstring'> 'Text to be displayed next to the input
renderLinefunctioncandidate => candidateUsed to transform the output of each line
searchOptionsObjectsee belowCustom search options
searchOptions.inputstring''Initial input
searchOptions.matchFieldfunctioncandidate => String( candidate )Selects which field will be used in the compare function
searchOptions.compareFunctionfunction( a, b ) => matchField( a).localeCompare( matchField( b ) )Defines how fields will be sorted after the search
searchOptions.limitnumberundefinedlimits the amount of candidates in the output
searchOptions.sortCandidatesbooleantruealphabetically sorts the candidates
1.2.0

5 years ago

1.1.3

5 years ago

1.1.2

5 years ago

1.1.1

5 years ago

1.1.0

5 years ago

1.0.4

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.3

5 years ago

1.0.0

5 years ago