Luna/libos/include/os/Prompt.h
apio 5c9503ac71
All checks were successful
continuous-integration/drone/push Build is passing
libos+cp: Add prompt functionality
2023-07-08 18:30:39 +02:00

36 lines
1000 B
C++

/**
* @file Prompt.h
* @author apio (cloudapio.eu)
* @brief A few functions to get input from the user.
*
* @copyright Copyright (c) 2023, the Luna authors.
*
*/
#pragma once
#include <luna/StringView.h>
namespace os
{
/**
* @brief The default value for a conditional prompt.
*
*/
enum DefaultValue
{
DefaultNo = 0,
DefaultYes = 1
};
/**
* @brief Show a prompt asking a yes or no question to the user.
*
* @param prompt The prompt that will be shown, without the "[y/N]" part. This will be added automatically by the
* function.
* @param fallback The value to return if the user's input was not a valid yes or no answer.
* @return true If the user entered 'y', 'Y', or the default value was yes and the input was invalid.
* @return false If the user entered 'n', 'N', or the default value was no and the input was invalid.
*/
bool conditional_prompt(StringView prompt, DefaultValue fallback);
}