131 lines
2.8 KiB
C
131 lines
2.8 KiB
C
|
///@ main.c
|
||
|
|
||
|
#include <stdlib.h>
|
||
|
#include <argp.h>
|
||
|
|
||
|
#include "calibrate.h"
|
||
|
#include "install.h"
|
||
|
// #include "query.h"
|
||
|
// #include "list.h"
|
||
|
|
||
|
#define PROGRAM_NAME "modetw" ///< Name of program
|
||
|
#define PROGRAM_VERSION "0.0.1" ///< Version of program
|
||
|
#define PROGRAM_ADDRESS "https://forge.chapril.org/pradana.aumars/modetw" ///< Web address of program
|
||
|
|
||
|
const char* argp_program_version = PROGRAM_NAME PROGRAM_VERSION;
|
||
|
const char* argp_program_bug_address = PROGRAM_ADDRESS;
|
||
|
|
||
|
static char doc[] =
|
||
|
PROGRAM_NAME " -- A utility tool for installing modifications for Empire: Total War";
|
||
|
|
||
|
static char args_doc[] = "";
|
||
|
|
||
|
static struct argp_option options[] = {
|
||
|
//{"help", 'h', 0, 0, "Show help menu" },
|
||
|
{"calibrate", 'c', 0, 0, "Calibrate game for mod installation" },
|
||
|
{"install", 'i', "MOD", 0, "Install MOD" },
|
||
|
{"uninstall", 'i', "MOD", 0, "Uninstall MOD" },
|
||
|
{"query", 'q', "MOD", 0, "Query MOD" },
|
||
|
{"list", 'l', 0, 0, "List installed mods" },
|
||
|
{ 0 }
|
||
|
};
|
||
|
|
||
|
struct arguments
|
||
|
{
|
||
|
int calibrate,install,uninstall,query,list;
|
||
|
char *mod;
|
||
|
};
|
||
|
|
||
|
static error_t
|
||
|
parse_opt (int key, char *arg, struct argp_state *state)
|
||
|
{
|
||
|
struct arguments *arguments = state->input;
|
||
|
|
||
|
switch (key)
|
||
|
{
|
||
|
case 'c':
|
||
|
arguments->calibrate = 1;
|
||
|
break;
|
||
|
case 'i':
|
||
|
arguments->install = 1;
|
||
|
arguments->mod = arg;
|
||
|
break;
|
||
|
case 'u':
|
||
|
arguments->uninstall = 1;
|
||
|
arguments->mod = arg;
|
||
|
break;
|
||
|
case 'q':
|
||
|
arguments->query = 1;
|
||
|
arguments->mod = arg;
|
||
|
break;
|
||
|
case 'l':
|
||
|
arguments->list = 1;
|
||
|
break;
|
||
|
|
||
|
default:
|
||
|
return ARGP_ERR_UNKNOWN;
|
||
|
}
|
||
|
return 0;
|
||
|
}
|
||
|
|
||
|
static struct argp argp = { options, parse_opt, args_doc, doc };
|
||
|
|
||
|
int
|
||
|
main(int argc, char **argv)
|
||
|
{
|
||
|
exception_t *e = NULL;
|
||
|
/*
|
||
|
if (!conf_verifygamedir())
|
||
|
{
|
||
|
fprintf(stderr, "Game directory not found!");
|
||
|
}
|
||
|
*/
|
||
|
struct arguments arguments;
|
||
|
|
||
|
/* Default values. */
|
||
|
arguments.calibrate = 0;
|
||
|
arguments.install = 0;
|
||
|
arguments.uninstall = 0;
|
||
|
arguments.query = 0;
|
||
|
arguments.list = 0;
|
||
|
arguments.mod = "";
|
||
|
|
||
|
argp_parse (&argp, argc, argv, 0, 0, &arguments);
|
||
|
|
||
|
if (arguments.install && arguments.uninstall) {
|
||
|
fprintf (stderr, "You cannot install and uninstall at the same time!\n");
|
||
|
exit (EXIT_FAILURE);
|
||
|
}
|
||
|
|
||
|
if (arguments.calibrate)
|
||
|
{
|
||
|
calibrate(e);
|
||
|
}
|
||
|
else if (arguments.install)
|
||
|
{
|
||
|
// install(arguments.mod);
|
||
|
fprintf(stderr, "Not implemented.\n");
|
||
|
exit (EXIT_FAILURE);
|
||
|
}
|
||
|
else if (arguments.uninstall)
|
||
|
{
|
||
|
// uninstall(arguments.mod);
|
||
|
fprintf(stderr, "Not implemented.\n");
|
||
|
exit (EXIT_FAILURE);
|
||
|
}
|
||
|
else if (arguments.query)
|
||
|
{
|
||
|
// query(arguments.mod);
|
||
|
fprintf(stderr, "Not implemented.\n");
|
||
|
exit (EXIT_FAILURE);
|
||
|
}
|
||
|
else if (arguments.list)
|
||
|
{
|
||
|
// list();
|
||
|
fprintf(stderr, "Not implemented.\n");
|
||
|
exit (EXIT_FAILURE);
|
||
|
}
|
||
|
|
||
|
exit (EXIT_SUCCESS);
|
||
|
}
|