ajwillia-ms pushed a commit to branch master. http://git.enlightenment.org/apps/equate.git/commit/?id=7989510b4c97ae89b68589156e0ef57f7296d72b
commit 7989510b4c97ae89b68589156e0ef57f7296d72b Author: Andy Williams <a...@andywilliams.me> Date: Sun Jan 10 12:30:08 2016 +0000 [commandline] add basic option parsing. Bringing some more features in will be easier with options. --- src/main.c | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) 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 @@ #include <Elementary.h> #ifndef ELM_LIB_QUICKLAUNCH +#include <Ecore_Getopt.h> + #include "Equate.h" #include "calc.h" @@ -53,6 +55,7 @@ static const struct NULL }; +#define COPYRIGHT "Copyright © 2004-2015 Andy Williams <a...@andyilliams.me>, \nNicolas Aguirre <aguirre.nico...@gmail.com> \nand various contributors (see AUTHORS)." static void _button_cb(void *data, Evas_Object * o EINA_UNUSED, @@ -293,9 +296,47 @@ _create_gui(void) _create_buttons(table); } +static const Ecore_Getopt optdesc = { + "equate", + "%prog [options]", + PACKAGE_VERSION, + COPYRIGHT, + "TODO check license", + "A calculator written with Enlightenment Foundation Libraries", + EINA_TRUE, + { +// ECORE_GETOPT_LICENSE('L', "license"), + ECORE_GETOPT_COPYRIGHT('C', "copyright"), + ECORE_GETOPT_VERSION('V', "version"), + ECORE_GETOPT_HELP('h', "help"), + ECORE_GETOPT_SENTINEL + } +}; + EAPI_MAIN int elm_main(int argc, char **argv) { + int args; + Eina_Bool quit_option = EINA_FALSE; + + Ecore_Getopt_Value values[] = { +// ECORE_GETOPT_VALUE_BOOL(quit_option), + ECORE_GETOPT_VALUE_BOOL(quit_option), + ECORE_GETOPT_VALUE_BOOL(quit_option), + ECORE_GETOPT_VALUE_BOOL(quit_option), + ECORE_GETOPT_VALUE_NONE + }; + + args = ecore_getopt_parse(&optdesc, values, argc, argv); + if (args < 0) + { + EINA_LOG_CRIT("Could not parse arguments."); + return 1; + } + else if (quit_option) + { + return 0; + } elm_policy_set(ELM_POLICY_QUIT, ELM_POLICY_QUIT_LAST_WINDOW_CLOSED); elm_app_compile_bin_dir_set(PACKAGE_BIN_DIR); --