Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/courajs/mkchoice
https://github.com/courajs/mkchoice
Last synced: 1 day ago
JSON representation
- Host: GitHub
- URL: https://github.com/courajs/mkchoice
- Owner: courajs
- Created: 2017-09-28T02:13:08.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2017-09-28T21:37:16.000Z (over 7 years ago)
- Last Synced: 2024-11-25T09:43:18.460Z (about 1 month ago)
- Language: JavaScript
- Size: 241 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# mkchoice
`mkchoice` is a tool for prompting a choice from a user, which is
compatible with shell pipelines:![Example usage of switching git branches](img/mkchoice.gif)
It does this by writing the prompt to the user's tty, instead of using
stdin/stdout.## Installation
Install with yarn or npm:
```sh
$ yarn global add mkchoice
```
```sh
$ npm install --global mkchoice
```## Docs
```
$ mkchoice -h
Usage: mkchoice [-h|--help] [-v|--vanish]
[-p|--prompt ] [-s|--selection ]
[args] [-- ]mkchoice prompts the user's tty to choose one of the given options,
and outputs the chosen option. Pass - as one of the args to also read
line-separated options from stdin. Arguments after -- are taken as
literal options, not interpreted as flags. If you pass no arguments,
mkchoice will read from stdin by default.You can pass the initially selected value with --selection, which
accepts the text of an option that will appear in the list, or an
index in the list. It defaults to the first item if the specified
one can't be found.Change the selected option with up/down or j/k, and confirm your
selection with space or enter.If the --vanish flag is given, the prompt will be erased from the
terminal before the output is shown. Otherwise, the final state of
the prompt will still be visible on the screen.Example:
$ seq 3 | mkchoice -s master a - b -p "Which one?" -- -p -h - -- master z >some-file
Which one?
a
1
2
3
b
-p
-h
-
--
> master
z
$ cat some-file
master
```