-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.c
executable file
·41 lines (34 loc) · 1.09 KB
/
main.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#include "app_ui/app_ui.h"
#include "project_variables.h"
#include <getopt.h>
#include <libintl.h>
static struct option long_options[] = {{"help", no_argument, NULL, 'h'},
{"version", no_argument, NULL, 'v'},
{0}};
static void printHelp(const char *programName);
int main(int argc, char **argv) {
int c, longIndex = 0;
while ((c = getopt_long(argc, argv, ":hv", long_options, &longIndex)) != -1) {
switch (c) {
case 'h':
printHelp(argv[0]);
return 0;
case 'v':
printf("%s %s\n", PROJECT_NAME, PROJECT_VERSION);
return 0;
default:
fprintf(stderr, "%s: Unknown option '%s'\n", argv[0], argv[optind - 1]);
printHelp(argv[0]);
return -1;
}
}
bindtextdomain(PROJECT_NAME, LOCALEDIR);
textdomain (PROJECT_NAME);
start_ui(argc, argv);
}
static void printHelp(const char *programName) {
printf("Usage: %s [options]\n", programName);
printf("\nOptions:\n");
printf(" -h, --help Prints this page\n");
printf(" -v, --version Shows program version\n");
}