<commit_before>pick [![Build Status](https://travis-ci.org/wong2/pick.svg?branch=master)](https://travis-ci.org/wong2/pick) [![PyPI](https://img.shields.io/pypi/v/pick.svg)](https://pypi.python.org/pypi/pick)
====

**pick** is a small python library to help you create curses based interactive selection
list in the terminal. See it in action:

![Demo](example/basic.gif?raw=true)


### Installation

    $ pip install pick

### Usage

**pick** comes with a simple api:

    >>> from pick import pick

    >>> title = 'Please choose your favorite programming language: '
    >>> options = ['Java', 'JavaScript', 'Python', 'PHP', 'C++', 'Erlang', 'Haskell']
    >>> option, index = pick(options, title)


**pick** multiselect example:

    >>> from pick import pick

    >>> title = 'Please choose your favorite programming language (press SPACE to mark, ENTER to continue): '
    >>> options = ['Java', 'JavaScript', 'Python', 'PHP', 'C++', 'Erlang', 'Haskell']
    >>> selected = pick(options, title, multi_select=True)
    >>> print selected
    >>> **output:** [ (Java, 0), (C++, 4) ]


#### Options

* `options`: a list of options to choose from
* `title`: (optional) a title above options list
* `multi_select`: (optional), if set to True its possible to select multiple items by hitting SPACE
* `indicator`: (optional) custom the selection indicator, defaults to *
* `default_index`: (optional) set this if the default selected option is not the first one


#### Register custom handlers

sometimes you may need to register custom handlers to specific keys, you can use the `register_custom_handler` API:

    >>> from pick import Picker
    >>> title, options = 'Title', ['Option1', 'Option2']
    >>> picker = Picker(options, title)
    >>> def go_back(picker):
    ...     return None, -1
    >>> picker.register_custom_handler(ord('h'),  go_back)<commit_msg>readme beautify<commit_after>pick [![Build Status](https://travis-ci.org/wong2/pick.svg?branch=master)](https://travis-ci.org/wong2/pick) [![PyPI](https://img.shields.io/pypi/v/pick.svg)](https://pypi.python.org/pypi/pick)
====

**pick** is a small python library to help you create curses based interactive selection
list in the terminal. See it in action:

![Demo](example/basic.gif?raw=true)


### Installation

    $ pip install pick

### Usage

**pick** comes with a simple api:

    >>> from pick import pick

    >>> title = 'Please choose your favorite programming language: '
    >>> options = ['Java', 'JavaScript', 'Python', 'PHP', 'C++', 'Erlang', 'Haskell']
    >>> option, index = pick(options, title)


**pick** multiselect example:

    >>> from pick import pick

    >>> title = 'Please choose your favorite programming language (press SPACE to mark, ENTER to continue): '
    >>> options = ['Java', 'JavaScript', 'Python', 'PHP', 'C++', 'Erlang', 'Haskell']
    >>> selected = pick(options, title, multi_select=True)
    >>> print selected

**outputs**
 
    >>> [ (Java, 0), (C++, 4) ]


#### Options

* `options`: a list of options to choose from
* `title`: (optional) a title above options list
* `multi_select`: (optional), if set to True its possible to select multiple items by hitting SPACE
* `indicator`: (optional) custom the selection indicator, defaults to *
* `default_index`: (optional) set this if the default selected option is not the first one


#### Register custom handlers

sometimes you may need to register custom handlers to specific keys, you can use the `register_custom_handler` API:

    >>> from pick import Picker
    >>> title, options = 'Title', ['Option1', 'Option2']
    >>> picker = Picker(options, title)
    >>> def go_back(picker):
    ...     return None, -1
    >>> picker.register_custom_handler(ord('h'),  go_back)
{'fraction_non_alphanumeric': 0.15904838278535152, 'fraction_numerical': 0.0037423148890670943, 'mean_word_length': 4.161379310344827, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 93, 'https://': 8, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2904301', 'n_tokens_mistral': 1160, 'n_tokens_neox': 1090, 'n_words': 386}