https://github.com/nlm/cliprompt
Python CLI prompt library
https://github.com/nlm/cliprompt
Last synced: over 1 year ago
JSON representation
Python CLI prompt library
- Host: GitHub
- URL: https://github.com/nlm/cliprompt
- Owner: nlm
- Created: 2016-04-05T09:46:34.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2016-04-15T09:51:51.000Z (over 10 years ago)
- Last Synced: 2025-01-21T21:47:35.472Z (over 1 year ago)
- Language: Python
- Size: 6.84 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
cliprompt
=========
This tool helps you ask questions via CLI
Prompt
------
Prompt is a single-line prompt and will loop until a correct answer
is detected. It is based on argparse, so arguments "choices", "type",
and "default" work the same way
Example:
>>> from cliprompt import Prompt
>>> prompt = Prompt(choices=['blue', 'red', 'yellow'])
>>> result = prompt.prompt('what color do you prefer ?')
>>> print('your favorite color is {}'.format(result))
what color do you prefer ? ('blue', 'red', 'yellow') green
argument answer: invalid choice: 'green' (choose from 'blue', 'red', 'yellow')
what color do you prefer ? ('blue', 'red', 'yellow') blue
your favorite color is blue
MultiPrompt
-----------
MultiPrompt is a multi-line prompt. It will acquire lines until a line
with only the EOF string is reached. This defaults to '.'
Example:
>>> from cliprompt import MultiPrompt
>>> prompt = MultiPrompt()
>>> result = prompt.prompt('enter text:')
>>> print('***')
>>> print(result)
>>> print('***')
enter text: (finish with ".")
hello world
this is a test
.
***
hello world
this is a test
***