36 lines
1000 B
C
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);
|
||
|
}
|