mirror of
https://github.com/CalcProgrammer1/OpenRGB.git
synced 2026-02-07 05:41:13 -05:00
Amending CLI code for "All Devices" to resolve #2918
* Adding `current_devices->size() == 0` check to Mode / Color / Brightness argument parsers to catch "All Devices" case from CLI
This commit is contained in:
95
cli.cpp
95
cli.cpp
@@ -641,30 +641,47 @@ bool OptionZone(std::vector<DeviceOptions>* current_devices, std::string argumen
|
||||
return found;
|
||||
}
|
||||
|
||||
bool OptionColor(std::vector<DeviceOptions>* current_devices, std::string argument, Options* /*options*/)
|
||||
bool CheckColor(std::string argument, DeviceOptions* currentDevOpts)
|
||||
{
|
||||
bool found = false;
|
||||
|
||||
for(size_t i = 0; i < current_devices->size(); i++)
|
||||
if(ParseColors(argument, currentDevOpts))
|
||||
{
|
||||
DeviceOptions* currentDevOpts = ¤t_devices->at(i);
|
||||
currentDevOpts->hasOption = true;
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cout << "Error: Invalid color value: " + argument << std::endl;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if(ParseColors(argument, currentDevOpts))
|
||||
bool OptionColor(std::vector<DeviceOptions>* current_devices, std::string argument, Options* options)
|
||||
{
|
||||
/*---------------------------------------------------------*\
|
||||
| If a device is not selected i.e. size() == 0 |
|
||||
| then add color to allDeviceOptions |
|
||||
\*---------------------------------------------------------*/
|
||||
bool found = false;
|
||||
DeviceOptions* currentDevOpts = &options->allDeviceOptions;
|
||||
|
||||
if(current_devices->size() == 0)
|
||||
{
|
||||
found = CheckColor(argument, currentDevOpts);
|
||||
}
|
||||
else
|
||||
{
|
||||
for(size_t i = 0; i < current_devices->size(); i++)
|
||||
{
|
||||
currentDevOpts->hasOption = true;
|
||||
found = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cout << "Error: Invalid color value: " + argument << std::endl;
|
||||
return false;
|
||||
currentDevOpts = ¤t_devices->at(i);
|
||||
|
||||
found = CheckColor(argument, currentDevOpts);
|
||||
}
|
||||
}
|
||||
|
||||
return found;
|
||||
}
|
||||
|
||||
bool OptionMode(std::vector<DeviceOptions>* current_devices, std::string argument, Options* /*options*/)
|
||||
bool OptionMode(std::vector<DeviceOptions>* current_devices, std::string argument, Options* options)
|
||||
{
|
||||
if(argument.size() == 0)
|
||||
{
|
||||
@@ -672,21 +689,35 @@ bool OptionMode(std::vector<DeviceOptions>* current_devices, std::string argumen
|
||||
return false;
|
||||
}
|
||||
|
||||
bool found = false;
|
||||
/*---------------------------------------------------------*\
|
||||
| If a device is not selected i.e. size() == 0 |
|
||||
| then add mode to allDeviceOptions |
|
||||
\*---------------------------------------------------------*/
|
||||
bool found = false;
|
||||
DeviceOptions* currentDevOpts = &options->allDeviceOptions;
|
||||
|
||||
for(size_t i = 0; i < current_devices->size(); i++)
|
||||
if(current_devices->size() == 0)
|
||||
{
|
||||
DeviceOptions* currentDevOpts = ¤t_devices->at(i);
|
||||
|
||||
currentDevOpts->mode = argument;
|
||||
currentDevOpts->hasOption = true;
|
||||
found = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
for(size_t i = 0; i < current_devices->size(); i++)
|
||||
{
|
||||
currentDevOpts = ¤t_devices->at(i);
|
||||
|
||||
currentDevOpts->mode = argument;
|
||||
currentDevOpts->hasOption = true;
|
||||
found = true;
|
||||
}
|
||||
}
|
||||
|
||||
return found;
|
||||
}
|
||||
|
||||
bool OptionBrightness(std::vector<DeviceOptions>* current_devices, std::string argument, Options* /*options*/)
|
||||
bool OptionBrightness(std::vector<DeviceOptions>* current_devices, std::string argument, Options* options)
|
||||
{
|
||||
if(argument.size() == 0)
|
||||
{
|
||||
@@ -694,16 +725,30 @@ bool OptionBrightness(std::vector<DeviceOptions>* current_devices, std::string a
|
||||
return false;
|
||||
}
|
||||
|
||||
bool found = false;
|
||||
/*---------------------------------------------------------*\
|
||||
| If a device is not selected i.e. size() == 0 |
|
||||
| then add brightness to allDeviceOptions |
|
||||
\*---------------------------------------------------------*/
|
||||
bool found = false;
|
||||
DeviceOptions* currentDevOpts = &options->allDeviceOptions;
|
||||
|
||||
for(size_t i = 0; i < current_devices->size(); i++)
|
||||
if(current_devices->size() == 0)
|
||||
{
|
||||
DeviceOptions* currentDevOpts = ¤t_devices->at(i);
|
||||
|
||||
currentDevOpts->brightness = std::min(std::max(std::stoi(argument), 0),(int)brightness_percentage);
|
||||
currentDevOpts->hasOption = true;
|
||||
currentDevOpts->brightness = std::min(std::max(std::stoi(argument), 0),(int)brightness_percentage);
|
||||
currentDevOpts->hasOption = true;
|
||||
found = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
for(size_t i = 0; i < current_devices->size(); i++)
|
||||
{
|
||||
DeviceOptions* currentDevOpts = ¤t_devices->at(i);
|
||||
|
||||
currentDevOpts->brightness = std::min(std::max(std::stoi(argument), 0),(int)brightness_percentage);
|
||||
currentDevOpts->hasOption = true;
|
||||
found = true;
|
||||
}
|
||||
}
|
||||
|
||||
return found;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user