Skip to content
/ qupp Public

A library for creating interactive command-line prompts in C++.

Notifications You must be signed in to change notification settings

tony-go/qupp

Repository files navigation

🚧 Disclaimer: This project is currently under development and might not be production-ready.

qupp

qupp is a lightweight library designed to simplify the user input prompt process in C++ applications.

🌟 Features

  • 🎉 Simplified user input prompts.
  • 🌍 Cross-platform (work in progress).
  • 🛠️ CMake-friendly integration (work in progress)

📖 Usage (API)

Prompt::ask_for_input

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;
}

Prompt::select

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;
}

Prompt::select_multiple

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";
  }
}

🤝 Contributing

Building

  1. Clone the repository:
    git clone https://github.com/tony-go/qupp.git
  2. Build
    make

🧪 Testing

Tests are implemented using Google Test.

After building, run:

make test

📜 License

MIT License. See LICENSE for more information.

About

A library for creating interactive command-line prompts in C++.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published