aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--main.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/main.c b/main.c
index bbc7c35..4e544ac 100644
--- a/main.c
+++ b/main.c
@@ -99,6 +99,7 @@ static void help(const char *argv0) {
99 "\nAvailable options:\n" 99 "\nAvailable options:\n"
100 " -r,--run=file.lua run input file\n" 100 " -r,--run=file.lua run input file\n"
101 " -b,--bundle bundles this folder\n" 101 " -b,--bundle bundles this folder\n"
102 " -d,--debug prints debug information\n"
102 " -h,--help this help\n" 103 " -h,--help this help\n"
103 " -v,--version show version\n", 104 " -v,--version show version\n",
104 argv0); 105 argv0);
@@ -109,9 +110,13 @@ static void version(const char *argv0) {
109} 110}
110 111
111int main(int argc, char *argv[]) { 112int main(int argc, char *argv[]) {
112 const char short_options[] = "r:bhv"; 113 TraceLogLevel debug_level = LOG_WARNING;
114 const char *run_file = NULL;
115
116 const char short_options[] = "r:dbhv";
113 const struct option long_options[] = { 117 const struct option long_options[] = {
114 { "run", 1, NULL, 'r' }, 118 { "run", 1, NULL, 'r' },
119 { "debug", 0, NULL, 'd' },
115 { "bundle", 0, NULL, 'b' }, 120 { "bundle", 0, NULL, 'b' },
116 { "help", 0, NULL, 'h' }, 121 { "help", 0, NULL, 'h' },
117 { "version", 0, NULL, 'v' }, 122 { "version", 0, NULL, 'v' },
@@ -119,7 +124,6 @@ int main(int argc, char *argv[]) {
119 }; 124 };
120 125
121 int opt; 126 int opt;
122 const char *run_file = NULL;
123 while ((opt = getopt_long(argc, argv, short_options, long_options, NULL)) != -1) { 127 while ((opt = getopt_long(argc, argv, short_options, long_options, NULL)) != -1) {
124 switch (opt) { 128 switch (opt) {
125 case 'r': 129 case 'r':
@@ -128,6 +132,9 @@ int main(int argc, char *argv[]) {
128 case 'b': 132 case 'b':
129 printf("TODO: Bundler\n"); 133 printf("TODO: Bundler\n");
130 return 0; 134 return 0;
135 case 'd':
136 debug_level = LOG_DEBUG;
137 break;
131 case 'h': 138 case 'h':
132 help(argv[0]); 139 help(argv[0]);
133 return 0; 140 return 0;
@@ -141,7 +148,7 @@ int main(int argc, char *argv[]) {
141 } 148 }
142 149
143 if (run_file) { 150 if (run_file) {
144 SetTraceLogLevel(DEBUG_LEVEL); 151 SetTraceLogLevel(debug_level);
145 152
146 lua_State *L = luaL_newstate(); 153 lua_State *L = luaL_newstate();
147 luaL_openlibs(L); 154 luaL_openlibs(L);