🚧 Disclaimer: This project is currently under development and might not be production-ready.
qupp is a lightweight library designed to simplify the user input prompt process in C++ applications.
- 🎉 Simplified user input prompts.
- 🌍 Cross-platform (work in progress).
- 🛠️ CMake-friendly integration (work in progress)
Prompts the user for input with the provided question.
Parameter | Type | Description |
---|---|---|
question |
std::string |
The question to present to the user. |
Returns: std::optional<std::string>
containing the user's input if provided, or an empty optional if the user provides no input.
#include <qupp/prompt/prompt.h>
int main() {
qupp::prompt::Prompt prompt;
auto result = prompt.ask_for_input("What's your name? ");
std::cout << "Hello, " << result.value() << "!" << std::endl;
return 0;
}
Presents a list of options to the user and allows them to select one.
Parameter | Type | Description |
---|---|---|
question |
std::string |
The question to present to the user. |
options |
std::vector<std::string> |
A list of options for the user to select from. |
Returns: std::optional<std::string>
containing the selected option or empty if no selection was made.
#include <qupp/prompt/prompt.h>
int main() {
qupp::prompt::Prompt prompt;
auto selected = prompt.select(
"Select an option:", {"Option 1", "Option 2", "Option 3 "});
if (selected.has_value()) {
std::cout << "You selected: " << selected.value() << "\n";
} else {
std::cout << "You did not select anything."
<< "\n";
}
return 0;
}
Presents a list of options to the user and allows them to select multiple.
Parameter | Type | Description |
---|---|---|
question |
std::string |
The question to present to the user. |
options |
std::vector<std::string> |
A list of options for the user to select from. |
Returns: std::optional<std::vector<std::string>>
containing the selected options or empty if no selections were made.
#include <qupp/prompt/prompt.h>
int main() {
auto choices = prompt.select_multiple("Select multiple options:",
{"Option 1", "Option 2", "Option 3 "});
if (choices.has_value()) {
std::cout << "You selected: ";
for (const auto &choice : choices.value()) {
std::cout << choice << " ";
}
std::cout << "\n";
} else {
std::cout << "You did not select anything."
<< "\n";
}
}
- Clone the repository:
git clone https://github.com/tony-go/qupp.git
- Build
make
Tests are implemented using Google Test.
After building, run:
make test
MIT License. See LICENSE
for more information.