/[sudobot]/trunk/lib/common/main.c
ViewVC logotype

Contents of /trunk/lib/common/main.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 575 - (show annotations)
Mon Jul 29 17:59:26 2024 UTC (8 months ago) by rakinar2
File MIME type: text/x-c
File size: 1439 byte(s)
chore: add trunk
1 #include <concord/discord.h>
2 #include <concord/log.h>
3 #include <stdio.h>
4 #include <stdbool.h>
5 #include <string.h>
6 #include <stdlib.h>
7 #include <getopt.h>
8
9 #include "core/command.h"
10 #include "events/on_message.h"
11 #include "events/on_ready.h"
12 #include "io/printf.h"
13 #include "sudobot.h"
14 #include "utils/strutils.h"
15 #include "flags.h"
16
17 #define ENV_BOT_TOKEN "BOT_TOKEN"
18
19 static struct option const long_options[] = {
20 { "update", no_argument, NULL, 'u' },
21 { "env", required_argument, NULL, 'e' },
22 { 0, 0, 0, 0 }
23 };
24
25 int main(int argc, char **argv)
26 {
27 int longind = 0;
28 const char *shortopts = "ue:";
29
30 opterr = 0;
31
32 while (true)
33 {
34 int c = getopt_long(argc, argv, shortopts, long_options, &longind);
35
36 if (c == -1)
37 break;
38
39 switch (c)
40 {
41 case 'u':
42 flags_add(FLAG_UPDATE_COMMANDS);
43 log_info("Update of the commands has been queued");
44 break;
45
46 case 'e':
47 opt_env_file_path = strdup(optarg);
48 break;
49
50 default:
51 if (optopt == 0)
52 log_error("Unknown option -- '%s'", argv[optind]);
53 else
54 log_error("Unknown option -- '%c'", optopt);
55
56 exit(EXIT_FAILURE);
57 break;
58 }
59 }
60
61 sudobot_start();
62 return 0;
63 }

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26