| 502 | namespace graph_internal |
| 503 | { |
| 504 | void handle_command(ConsoleServer &cs, u32 client_id, const JsonArray &args, void * /*user_data*/) |
| 505 | { |
| 506 | TempAllocator1024 ta; |
| 507 | |
| 508 | if (array::size(args) < 2) { |
| 509 | cs.error(client_id, "Usage: graph make <name>"); |
| 510 | return; |
| 511 | } |
| 512 | |
| 513 | DynamicString subcmd(ta); |
| 514 | sjson::parse_string(subcmd, args[1]); |
| 515 | if (subcmd == "help") { |
| 516 | logi(GRAPH, "make Create a new graph."); |
| 517 | logi(GRAPH, "list List graphs."); |
| 518 | logi(GRAPH, "range Set the range of a graph."); |
| 519 | logi(GRAPH, "add Add a field to a graph."); |
| 520 | logi(GRAPH, "remove Remove a field from a graph."); |
| 521 | logi(GRAPH, "hide Hide a graph."); |
| 522 | logi(GRAPH, "show Show a graph."); |
| 523 | logi(GRAPH, "layout Set the layout of a graph."); |
| 524 | logi(GRAPH, "color Set the color of a field in a graph."); |
| 525 | logi(GRAPH, "samples Set the number of samples to show in a graph."); |
| 526 | } else if (subcmd == "make") { |
| 527 | if (array::size(args) != 3) { |
| 528 | cs.error(client_id, "Usage: graph make <name>"); |
| 529 | return; |
| 530 | } |
| 531 | |
| 532 | DynamicString name(ta); |
| 533 | sjson::parse_string(name, args[2]); |
| 534 | |
| 535 | Graph *graph = graph::find(_graphs, name.c_str()); |
| 536 | if (graph != NULL) { |
| 537 | cs.error(client_id, "Graph with this name already exists"); |
| 538 | return; |
| 539 | } |
| 540 | graph::create(_graphs, name.c_str()); |
| 541 | } else if (subcmd == "list") { |
| 542 | ListNode *cur; |
| 543 | list_for_each(cur, &_graphs) |
| 544 | { |
| 545 | Graph *graph = (Graph *)container_of(cur, Graph, _node); |
| 546 | logi(GRAPH, "%s", graph->_name.c_str()); |
| 547 | } |
| 548 | } else if (subcmd == "range") { |
| 549 | if (array::size(args) != 3 && array::size(args) != 5) { |
| 550 | cs.error(client_id, "Usage: graph range <graph> [min max]"); |
| 551 | return; |
| 552 | } |
| 553 | |
| 554 | DynamicString name(ta); |
| 555 | DynamicString min(ta); |
| 556 | DynamicString max(ta); |
| 557 | sjson::parse_string(name, args[2]); |
| 558 | if (array::size(args) == 5) { |
| 559 | sjson::parse_string(min, args[3]); |
| 560 | sjson::parse_string(max, args[4]); |
| 561 | } else { |
nothing calls this directly
no test coverage detected