| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192 |
- /*
- * This file is part of RuneOptimizer.
- *
- * RuneOptimizer is free software: you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the Free
- * Software Foundation, either version 3 of the License, or (at your option)
- * any later version.
- *
- * RuneOptimizer is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * You should have received a copy of the GNU General Public License along with
- * RuneOptimizer. If not, see <https://www.gnu.org/licenses/>.
- */
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- #include <sqlite3.h>
- #include <math.h>
- #include "RuneOptimizer.h"
- #include "error/error.h"
- #include "help/help.h"
- #include "help/help.c"
- #include "optimize/optimize.h"
- #include "optimize/optimize.c"
- #include "team/team.h"
- #include "team/team.c"
- #include "update/update.h"
- #include "update/update.c"
- /**
- * Starts the program.
- *
- * Reads parameters and runs the appropiate functions.
- *
- * @param argc Argument count.
- * @param argv Argument list.
- * @return SUCCESS on success, other on error.
- */
- int main(int argc, char *argv[]){
- // Parse the arguments to find the command (index 1)
- // If no arguments, end here
- if (argc < 2){
- fprintf(stderr, "No command specified\n");
- return ERROR_INPUT_NO_COMMAND;
- }
- // Update command, TODO
- if (strcmp(argv[1], "update") == 0){
- fprintf(stderr, "Updating is still unimplemented\n");
- return UNIMPLEMENTED;
- }
- // Optimize command, call the function with all the arguments to be
- // processed there.
- else if (strcmp(argv[1], "optimize") == 0){
- int result = optimize(argc, argv);
- return result;
- }
- // Help command. Call and return
- else if (strcmp(argv[1], "help") == 0){
- show_help();
- return SUCCESS;
- }
- // Help command. Call and return
- else if (strcmp(argv[1], "team") == 0){
- if (argc < 3){
- fprintf(stderr, "Command team needs an action\n");
- return ERROR_INPUT_TEAM_NO_ACTION;
- }
- if (strcmp(argv[2], "list") == 0){
- int result = list_teams(argc, argv);
- return result;
- }
- else{
- fprintf(stderr, "Invalid action for team command: %s\n", argv[1]);
- return ERROR_INPUT_TEAM_INVALID_ACTION;
- }
- }
- // Any other command is an error
- else{
- fprintf(stderr, "Invalid command specified: %s\n", argv[1]);
- return ERROR_INPUT_INVALID_COMMAND;
- }
- }
|