add a default set of initialisation options for cli flags
This commit is contained in:
parent
867bbb1c37
commit
9d255f7948
1
TODO.gmi
1
TODO.gmi
@ -22,3 +22,4 @@ A list of things I'd like to accomplish
|
|||||||
* Handle mod dependencies
|
* Handle mod dependencies
|
||||||
* Remove rendering from serverside
|
* Remove rendering from serverside
|
||||||
* Client-side resource files for each mod
|
* Client-side resource files for each mod
|
||||||
|
* Real error handling (right now I just pass up to main and immediately exit)
|
||||||
|
@ -9,13 +9,17 @@
|
|||||||
int main(int argc, char **argv) {
|
int main(int argc, char **argv) {
|
||||||
enum error_t err = ERR_OK;
|
enum error_t err = ERR_OK;
|
||||||
|
|
||||||
struct options_t options = { false };
|
struct options_t options = { 0 };
|
||||||
|
opts_default(&options);
|
||||||
|
|
||||||
err = opts_parse(&options, argc, argv);
|
err = opts_parse(&options, argc, argv);
|
||||||
if (err) goto handle_error;
|
if (err) goto handle_error;
|
||||||
|
|
||||||
err = opts_init(&options);
|
err = opts_init(&options);
|
||||||
if (err) goto handle_error;
|
if (err) goto handle_error;
|
||||||
|
|
||||||
|
// Open a socket and connect to clients
|
||||||
|
|
||||||
opts_free(&options);
|
opts_free(&options);
|
||||||
return ERR_OK;
|
return ERR_OK;
|
||||||
|
|
||||||
|
@ -9,6 +9,11 @@
|
|||||||
#include "opts.h"
|
#include "opts.h"
|
||||||
#include "daemon.h"
|
#include "daemon.h"
|
||||||
|
|
||||||
|
void opts_default(struct options_t *options) {
|
||||||
|
options->daemonise = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
enum error_t opts_parse(struct options_t *options, int argc, char **argv) {
|
enum error_t opts_parse(struct options_t *options, int argc, char **argv) {
|
||||||
struct option const long_options[] = {
|
struct option const long_options[] = {
|
||||||
{ "daemon", no_argument, 0, 'd' },
|
{ "daemon", no_argument, 0, 'd' },
|
||||||
|
@ -9,6 +9,7 @@ struct options_t {
|
|||||||
bool daemonise;
|
bool daemonise;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
void opts_default(struct options_t *);
|
||||||
enum error_t opts_parse(struct options_t *, int, char **);
|
enum error_t opts_parse(struct options_t *, int, char **);
|
||||||
enum error_t opts_init(struct options_t const *);
|
enum error_t opts_init(struct options_t const *);
|
||||||
void opts_free(struct options_t const *);
|
void opts_free(struct options_t const *);
|
||||||
|
Loading…
Reference in New Issue
Block a user