[API] Implement Zone Sidecar (#3635)

* Zone sidecar work

* Process management work

* Merge

* Sidecar work

* API config option

* Request proxy work

* Proxy headers and params

* Change port

* Remove code

* Sim work

* Sidecar work

* Update loot_simulator_controller.cpp

* Update loot_simulator_controller.cpp

* Formatting

* Post merge change

* Windows compile fix

* Update sidecar_api.cpp

* Update strings.cpp
This commit is contained in:
Chris Miles
2023-10-23 22:39:37 -05:00
committed by GitHub
parent 0bbfcf7adc
commit b027edd21e
22 changed files with 25282 additions and 127 deletions
+20 -27
View File
@@ -39,15 +39,15 @@ namespace EQEmuCommand {
{
if (cmd[{"-d", "--debug"}]) {
std::cout << "Positional args:\n";
for (auto &pos_arg : cmd.pos_args())
for (auto &pos_arg: cmd.pos_args())
std::cout << '\t' << pos_arg << std::endl;
std::cout << "\nFlags:\n";
for (auto &flag : cmd.flags())
for (auto &flag: cmd.flags())
std::cout << '\t' << flag << std::endl;
std::cout << "\nParameters:\n";
for (auto &param : cmd.params())
for (auto &param: cmd.params())
std::cout << '\t' << param.first << " : " << param.second << std::endl;
}
}
@@ -69,8 +69,8 @@ namespace EQEmuCommand {
{
bool arguments_filled = true;
int index = 2;
for (auto &arg : arguments) {
int index = 2;
for (auto &arg: arguments) {
if (cmd(arg).str().empty() && cmd(index).str().empty()) {
arguments_filled = false;
}
@@ -79,12 +79,12 @@ namespace EQEmuCommand {
if (!arguments_filled || (argc == 2 && !cmd[{"-h", "--help"}]) || (argc == 3 && cmd[{"-h", "--help"}])) {
std::string arguments_string;
for (auto &arg : arguments) {
for (auto &arg: arguments) {
arguments_string += " " + arg;
}
std::string options_string;
for (auto &opt : options) {
for (auto &opt: options) {
options_string += " " + opt + "\n";
}
@@ -124,14 +124,6 @@ namespace EQEmuCommand {
)
{
std::string description;
bool ran_command = false;
for (auto &it: in_function_map) {
if (it.first == argv[1]) {
(it.second)(argc, argv, cmd, description);
ran_command = true;
}
}
if (cmd[{"-h", "--help"}]) {
std::cout << std::endl;
std::cout <<
@@ -142,9 +134,7 @@ namespace EQEmuCommand {
<< std::endl
<< std::endl;
/**
* Get max command length for padding length
*/
// Get max command length for padding length
int max_command_length = 0;
for (auto &it: in_function_map) {
@@ -155,18 +145,14 @@ namespace EQEmuCommand {
}
}
/**
* Display command menu
*/
// Display command menu
std::string command_section;
for (auto &it: in_function_map) {
description.clear();
(it.second)(argc, argv, cmd, description);
/**
* Print section header
*/
// Print section header
std::string command_prefix = it.first.substr(0, it.first.find(":"));
if (command_prefix.find("test") != std::string::npos) {
@@ -178,9 +164,7 @@ namespace EQEmuCommand {
std::cout << termcolor::reset << command_prefix << std::endl;
}
/**
* Print commands
*/
// Print commands
std::stringstream command;
command << termcolor::colorize << termcolor::yellow << it.first << termcolor::reset;
printf(" %-*s %s\n", max_command_length, command.str().c_str(), description.c_str());
@@ -191,6 +175,15 @@ namespace EQEmuCommand {
std::exit(0);
}
bool ran_command = false;
for (auto &it: in_function_map) {
if (it.first == argv[1]) {
(it.second)(argc, argv, cmd, description);
ran_command = true;
}
}
if (ran_command) {
std::exit(0);
}