Merge pull request #2778 from defnax/service-text-coloring

Added colors for the service output
This commit is contained in:
csoler 2023-10-25 23:09:45 +02:00 committed by GitHub
commit c52e84d709
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -60,7 +60,7 @@ public:
bool /*prev_is_bad*/, std::string& password, bool& cancel ) bool /*prev_is_bad*/, std::string& password, bool& cancel )
{ {
std::string question1 = title + std::string question1 = title +
"\nPlease enter your PGP password for key:\n " + "\033[0;32mPlease enter your PGP password for key:\n \033[0m" +
question + " :"; question + " :";
password = RsUtil::rs_getpass(question1.c_str()) ; password = RsUtil::rs_getpass(question1.c_str()) ;
cancel = false ; cancel = false ;
@ -182,9 +182,9 @@ int main(int argc, char* argv[])
while(keepRunning) while(keepRunning)
{ {
webui_pass1 = RsUtil::rs_getpass( webui_pass1 = RsUtil::rs_getpass(
"Please register a password for the web interface: " ); "\033[0;32mPlease register a password for the web interface:\033[0m" );
webui_pass2 = RsUtil::rs_getpass( webui_pass2 = RsUtil::rs_getpass(
"Please enter the same password again : " ); "\033[0;32mPlease enter the same password again :\033[0m" );
if(webui_pass1 != webui_pass2) if(webui_pass1 != webui_pass2)
{ {
@ -223,28 +223,28 @@ int main(int argc, char* argv[])
if(locations.size() == 0) if(locations.size() == 0)
{ {
RsErr() << "No available accounts. You cannot use option -U list" << std::endl; RsErr() << "\033[1;33mNo available accounts. You cannot use option -U list\033[0m" << std::endl;
return -RsInit::ERR_NO_AVAILABLE_ACCOUNT; return -RsInit::ERR_NO_AVAILABLE_ACCOUNT;
} }
std::cout << std::endl << std::endl std::cout << std::endl << std::endl
<< "Available accounts:" << std::endl; << "\033[0;32mAvailable accounts:\033[0m" << std::endl;
int accountCountDigits = static_cast<int>( ceil(log(locations.size())/log(10.0)) ); int accountCountDigits = static_cast<int>( ceil(log(locations.size())/log(10.0)) );
for( uint32_t i=0; i<locations.size(); ++i ) for( uint32_t i=0; i<locations.size(); ++i )
std::cout << "[" << std::setw(accountCountDigits) std::cout << "\033[0;32m[" << std::setw(accountCountDigits)
<< std::setfill('0') << i+1 << "] " << std::setfill('0') << i+1 << "]\033[0m "
<< locations[i].mLocationId << " (" << locations[i].mLocationId << "\033[0;35m ("
<< locations[i].mPgpId << "): " << locations[i].mPgpId << "): "
<< locations[i].mPgpName << locations[i].mPgpName
<< " \t (" << locations[i].mLocationName << ")" << " (" << locations[i].mLocationName << ")\033[0m"
<< std::endl; << std::endl;
uint32_t nacc = 0; uint32_t nacc = 0;
while(keepRunning && (nacc < 1 || nacc >= locations.size())) while(keepRunning && (nacc < 1 || nacc >= locations.size()))
{ {
std::cout << "Please enter account number: "; std::cout << "\033[0;32mPlease enter account number:\n\033[0m";
std::cout.flush(); std::cout.flush();
std::string inputStr; std::string inputStr;