Rewrite the entire code-base
The following changes are focused upon: - Modularity - Doing away with globals - No heap allocations - Better command line interface - Switch from Xlib to XCB - More verbose type definitions - Implement a single-file config by utilising X-macros
This commit is contained in:
30
src/cli.c
Normal file
30
src/cli.c
Normal file
@@ -0,0 +1,30 @@
|
||||
#include "cli.h"
|
||||
|
||||
#include <getopt.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdio.h>
|
||||
|
||||
int cli_init(cli_arguments *const args, const char *const argv[],
|
||||
const int argc) {
|
||||
args->is_debug_mode = false;
|
||||
|
||||
int opt = -1;
|
||||
opterr = 0; // Suppress getopt's built-in invalid opt message
|
||||
while ((opt = getopt(argc, (char *const *)argv, "dh")) != -1) {
|
||||
switch (opt) {
|
||||
case 'd':
|
||||
args->is_debug_mode = true;
|
||||
break;
|
||||
case 'h':
|
||||
// fall through
|
||||
case '?':
|
||||
(void)fprintf(stderr, "error: unknown option `-%c'\n", optopt);
|
||||
// fall through
|
||||
default:
|
||||
(void)fprintf(stderr, "usage: %s [-d]\n", BINARY);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user