Add new CLI option, separate auto-detect and auto-connect

This commit is contained in:
morg 2021-03-08 14:00:00 +01:00 committed by Adam Honse
parent 30c595c6d6
commit e1faa783b6
2 changed files with 24 additions and 5 deletions

13
cli.cpp
View file

@ -32,6 +32,7 @@ enum
RET_FLAG_NO_DETECT = 16, RET_FLAG_NO_DETECT = 16,
RET_FLAG_CLI_POST_DETECTION = 32, RET_FLAG_CLI_POST_DETECTION = 32,
RET_FLAG_START_SERVER = 64, RET_FLAG_START_SERVER = 64,
RET_FLAG_NO_AUTO_CONNECT = 128,
}; };
struct DeviceOptions struct DeviceOptions
@ -375,7 +376,8 @@ void OptionHelp()
help_text += " There is a risk of bricking your motherboard, RGB controller, and RAM if you send invalid SMBus/I2C transactions.\n"; help_text += " There is a risk of bricking your motherboard, RGB controller, and RAM if you send invalid SMBus/I2C transactions.\n";
help_text += "--localconfig Use the current working directory instead of the global configuration directory.\n"; help_text += "--localconfig Use the current working directory instead of the global configuration directory.\n";
help_text += "--config path Use a custom path instead of the global configuration directory.\n"; help_text += "--config path Use a custom path instead of the global configuration directory.\n";
help_text += "--nodetect Do not try to detect hardware or autoconnect to a local server at startup.\n"; help_text += "--nodetect Do not try to detect hardware at startup.\n";
help_text += "--noautoconnect Do not try to autoconnect to a local server at startup.\n";
std::cout << help_text << std::endl; std::cout << help_text << std::endl;
} }
@ -983,6 +985,15 @@ unsigned int cli_pre_detection(int argc, char *argv[])
cfg_args++; cfg_args++;
} }
/*---------------------------------------------------------*\
| --noautoconnect |
\*---------------------------------------------------------*/
else if(option == "--noautoconnect")
{
ret_flags |= RET_FLAG_NO_AUTO_CONNECT;
cfg_args++;
}
/*---------------------------------------------------------*\ /*---------------------------------------------------------*\
| --client | | --client |
\*---------------------------------------------------------*/ \*---------------------------------------------------------*/

View file

@ -37,6 +37,7 @@ enum
RET_FLAG_NO_DETECT = 16, RET_FLAG_NO_DETECT = 16,
RET_FLAG_CLI_POST_DETECTION = 32, RET_FLAG_CLI_POST_DETECTION = 32,
RET_FLAG_START_SERVER = 64, RET_FLAG_START_SERVER = 64,
RET_FLAG_NO_AUTO_CONNECT = 128,
}; };
/******************************************************************************************\ /******************************************************************************************\
@ -173,15 +174,13 @@ int main(int argc, char* argv[])
| Perform local connection and/or hardware detection if not | | Perform local connection and/or hardware detection if not |
| disabled from CLI | | disabled from CLI |
\*---------------------------------------------------------*/ \*---------------------------------------------------------*/
if(!(ret_flags & RET_FLAG_NO_DETECT)) if(!(ret_flags & RET_FLAG_NO_AUTO_CONNECT))
{ {
printf("Attempting to connect to local OpenRGB server.\r\n"); printf("Attempting to connect to local OpenRGB server.\r\n");
if(!AttemptLocalConnection()) if(!AttemptLocalConnection())
{ {
printf("Local OpenRGB server unavailable, running standalone.\r\n"); printf("Local OpenRGB server unavailable.\r\n");
ResourceManager::get()->DetectDevices();
} }
else else
{ {
@ -191,6 +190,15 @@ int main(int argc, char* argv[])
} }
} }
/*---------------------------------------------------------*\
| Perform hardware detection if not disabled from CLI |
\*---------------------------------------------------------*/
if(!(ret_flags & RET_FLAG_NO_DETECT))
{
printf("Running standalone.\r\n");
ResourceManager::get()->DetectDevices();
}
/*---------------------------------------------------------*\ /*---------------------------------------------------------*\
| Start the server if requested from CLI (this must be done | | Start the server if requested from CLI (this must be done |
| after attempting local connection!) | | after attempting local connection!) |