summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndy Williams <andy@andywilliams.me>2016-01-10 12:30:08 +0000
committerAndy Williams <andy@andywilliams.me>2016-01-10 12:30:08 +0000
commit7989510b4c97ae89b68589156e0ef57f7296d72b (patch)
tree114161b885da1d846b50d4b2c2706aafca249655
parent07990e0a3bd63bd5c984bb21751a6f08b3ac2ad7 (diff)
[commandline] add basic option parsing.
Bringing some more features in will be easier with options.
-rw-r--r--src/main.c41
1 files changed, 41 insertions, 0 deletions
diff --git a/src/main.c b/src/main.c
index ce24206..1f86b2f 100644
--- a/src/main.c
+++ b/src/main.c
@@ -1,6 +1,8 @@
1#include <Elementary.h> 1#include <Elementary.h>
2#ifndef ELM_LIB_QUICKLAUNCH 2#ifndef ELM_LIB_QUICKLAUNCH
3 3
4#include <Ecore_Getopt.h>
5
4#include "Equate.h" 6#include "Equate.h"
5#include "calc.h" 7#include "calc.h"
6 8
@@ -53,6 +55,7 @@ static const struct
53 NULL 55 NULL
54}; 56};
55 57
58#define COPYRIGHT "Copyright © 2004-2015 Andy Williams <andy@andyilliams.me>, \nNicolas Aguirre <aguirre.nicolas@gmail.com> \nand various contributors (see AUTHORS)."
56 59
57static void 60static void
58_button_cb(void *data, Evas_Object * o EINA_UNUSED, 61_button_cb(void *data, Evas_Object * o EINA_UNUSED,
@@ -293,9 +296,47 @@ _create_gui(void)
293 _create_buttons(table); 296 _create_buttons(table);
294} 297}
295 298
299static const Ecore_Getopt optdesc = {
300 "equate",
301 "%prog [options]",
302 PACKAGE_VERSION,
303 COPYRIGHT,
304 "TODO check license",
305 "A calculator written with Enlightenment Foundation Libraries",
306 EINA_TRUE,
307 {
308// ECORE_GETOPT_LICENSE('L', "license"),
309 ECORE_GETOPT_COPYRIGHT('C', "copyright"),
310 ECORE_GETOPT_VERSION('V', "version"),
311 ECORE_GETOPT_HELP('h', "help"),
312 ECORE_GETOPT_SENTINEL
313 }
314};
315
296EAPI_MAIN int 316EAPI_MAIN int
297elm_main(int argc, char **argv) 317elm_main(int argc, char **argv)
298{ 318{
319 int args;
320 Eina_Bool quit_option = EINA_FALSE;
321
322 Ecore_Getopt_Value values[] = {
323// ECORE_GETOPT_VALUE_BOOL(quit_option),
324 ECORE_GETOPT_VALUE_BOOL(quit_option),
325 ECORE_GETOPT_VALUE_BOOL(quit_option),
326 ECORE_GETOPT_VALUE_BOOL(quit_option),
327 ECORE_GETOPT_VALUE_NONE
328 };
329
330 args = ecore_getopt_parse(&optdesc, values, argc, argv);
331 if (args < 0)
332 {
333 EINA_LOG_CRIT("Could not parse arguments.");
334 return 1;
335 }
336 else if (quit_option)
337 {
338 return 0;
339 }
299 340
300 elm_policy_set(ELM_POLICY_QUIT, ELM_POLICY_QUIT_LAST_WINDOW_CLOSED); 341 elm_policy_set(ELM_POLICY_QUIT, ELM_POLICY_QUIT_LAST_WINDOW_CLOSED);
301 elm_app_compile_bin_dir_set(PACKAGE_BIN_DIR); 342 elm_app_compile_bin_dir_set(PACKAGE_BIN_DIR);