Interactive Terminal
interactive_terminal is a Python module that provides an easy-to-use interface for creating interactive command-line applications. With this module, developers can ask various types of questions, including text input, lists, confirmations, numeric inputs, ranges, and choices, all while validating user responses for a smooth user experience.
Features
- Supports multiple question types:
- Text Input: For open-ended questions.
- List Selection: Allows users to choose from a list of options.
- Confirmation: Simple yes/no questions.
- Numeric Input: For getting numeric responses.
- Range Selection: For selecting a range of values.
- Choice Selection: For picking one option from multiple choices.
- Input validation to ensure accurate and meaningful user responses.
- Easy integration into Python applications.
Installation
You can install the interactive_terminal module using pip. Open your terminal or command prompt and run:
pip install interactive_terminal
Usage
To use the interactive_terminal module, follow these steps:
- Import the necessary classes from the module.
- Define the questions you want to ask using the
Questionclass. - Call the
ask_questionsfunction to prompt the user and collect their responses.
Example
Here's a simple example demonstrating how to use the interactive_terminal module:
from interactive_terminal import Question, QuestionType, ask_questions
def main():
questions = [
Question(QuestionType.TEXT, "name", "What is your name?"),
Question(QuestionType.LIST, "favorite_color", "What is your favorite color?",
options=["Red", "Blue", "Green", "Yellow"]),
Question(QuestionType.CONFIRM, "like_programming", "Do you like programming?"),
Question(QuestionType.NUMBER, "experience_years", "How many years have you been programming?"),
Question(QuestionType.RANGE, "age_range", "What is your age range?",
options=["0-18", "19-30", "31-45", "46+"]),
Question(QuestionType.CHOICE, "os_choice", "Which operating system do you prefer?",
options=["Windows", "macOS", "Linux"])
]
answers = ask_questions(questions)
print("\nThank you for your answers! Here's what you provided:")
for key, value in answers.items():
print(f"{key.capitalize()}: {value}")
if __name__ == "__main__":
main()
Output
When you run the example code, it will prompt the user with a series of questions, like so:
[?] What is your name?:
The user can respond with their name, and the program will continue asking the rest of the questions in sequence, validating their input as specified.
Contributing
Contributions are welcome! If you have suggestions for improvements or new features, please email me and I will think about your request.
License
This project is licensed under the MIT License. See the LICENSE file for details.
Release files for interactive-terminal 0.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| interactive_terminal-0.2.tar.gz | 6.0 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| interactive_terminal-0.2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 12.8 kB
Release files / interactive_terminal-0.2.tar.gz
| Download URL | interactive_terminal-0.2.tar.gz |
|---|---|
| Size | 6.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
7f269ddd313bba13a289252b243395800733d5c19e6746d0f523ddf5cfa5d724
|
|
BLAKE2b-256 checksum How to use checksums |
aa4d1d3ddfe8e834b9c1bceb8e9b12a8140d3f216b2e9514f23e6f762cd83ebc
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.11.9
|
Release files / interactive_terminal-0.2-py3-none-any.whl
| Download URL | interactive_terminal-0.2-py3-none-any.whl |
|---|---|
| Size | 6.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
611f4b5e4e25574a4a9c47e775ceede633465fe1c4f3d5522baf94163b182db5
|
|
BLAKE2b-256 checksum How to use checksums |
0cd5d98d6e3257b39f3e6fa4c20b72bd68101e3fb33cbdaf100915f53509f6d4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.11.9
|