-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathInputUtils.h
More file actions
40 lines (22 loc) · 776 Bytes
/
Copy pathInputUtils.h
File metadata and controls
40 lines (22 loc) · 776 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#ifndef TRUSTEDINSTALLERELEVATION_INPUTUTILS_H
#define TRUSTEDINSTALLERELEVATION_INPUTUTILS_H
#include <string>
#include <iostream>
namespace InputUtils {
inline std::string getUserInput(const std::string &prompt, const std::string& defaultValue) {
std::string input;
if (!defaultValue.empty()) {
std::cout << prompt << " (default: " << defaultValue << "): ";
} else {
std::cout << prompt << ": ";
}
// Get the user input
std::getline(std::cin, input);
// Return the default value if input is empty
if (input.empty()) {
return defaultValue;
}
return input;
}
} // namespace InputUtils
#endif // TRUSTEDINSTALLERELEVATION_INPUTUTILS_H