diff --git a/meson.build b/meson.build index fbbbf64..dd90465 100644 --- a/meson.build +++ b/meson.build @@ -46,6 +46,7 @@ eg25_datadir = join_paths(full_datadir, meson.project_name()) add_global_arguments('-D@0@="@1@"'.format('EG25_CONFDIR', eg25_confdir), language : 'c') add_global_arguments('-D@0@="@1@"'.format('EG25_DATADIR', eg25_datadir), language : 'c') +add_global_arguments('-D@0@="@1@"'.format('EG25_VERSION', meson.project_version()), language : 'c') mmglib_dep = dependency('mm-glib', required : false) if mmglib_dep.found() diff --git a/src/manager.c b/src/manager.c index 67bd0ae..f725eb7 100644 --- a/src/manager.c +++ b/src/manager.c @@ -34,6 +34,10 @@ #define EG25_DATADIR "/usr/share/eg25-manager" #endif +#ifndef EG25_VERSION +#define EG25_VERSION "0.0.0" +#endif + #define POWERON_DELAY_US 100000UL static gboolean quit_app(struct EG25Manager *manager) @@ -286,10 +290,12 @@ int main(int argc, char *argv[]) g_autoptr(GError) err = NULL; struct EG25Manager manager; gchar *config_file = NULL; + gboolean show_version = FALSE; toml_table_t *toml_config[EG25_CONFIG_COUNT]; toml_table_t *manager_config[EG25_CONFIG_COUNT]; const GOptionEntry options[] = { { "config", 'c', 0, G_OPTION_ARG_STRING, &config_file, "Config file to use.", NULL }, + { "version", 'v', 0, G_OPTION_ARG_NONE, &show_version, "Display version information and exit.", NULL }, { NULL, 0, 0, G_OPTION_ARG_NONE, NULL, NULL, NULL } }; @@ -306,6 +312,11 @@ int main(int argc, char *argv[]) return 1; } + if (show_version) { + printf("eg25-manager version %s\n", EG25_VERSION); + return 0; + } + manager.loop = g_main_loop_new(NULL, FALSE); toml_config[EG25_CONFIG_SYS] = parse_config_file(NULL, TRUE);