forked from enlightenment/equate
[commandline] add basic option parsing.
Bringing some more features in will be easier with options.
This commit is contained in:
parent
07990e0a3b
commit
7989510b4c
41
src/main.c
41
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 <andy@andyilliams.me>, \nNicolas Aguirre <aguirre.nicolas@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);
|
||||
|
|
Loading…
Reference in New Issue