diff --git a/client/agent.c b/client/agent.c
index e8ca4dd..70c3248 100644
--- a/client/agent.c
+++ b/client/agent.c
#include <unistd.h>
#include <string.h>
+#include <glib.h>
+
#include "src/shared/shell.h"
#include "gdbus/gdbus.h"
#include "agent.h"
diff --git a/client/main.c b/client/main.c
index 7661b33..98123d5 100644
--- a/client/main.c
+++ b/client/main.c
int main(int argc, char *argv[])
{
- GOptionContext *context;
- GError *error = NULL;
GDBusClient *client;
auto_register_agent = g_strdup("");
- context = g_option_context_new(NULL);
- g_option_context_add_main_entries(context, options, NULL);
-
- if (g_option_context_parse(context, &argc, &argv, &error) == FALSE) {
- if (error != NULL) {
- g_printerr("%s\n", error->message);
- g_error_free(error);
- } else
- g_printerr("An unknown error occurred\n");
- exit(1);
- }
-
- g_option_context_free(context);
-
- bt_shell_init(&argc, &argv);
+ bt_shell_init(&argc, &argv, options);
bt_shell_set_menu(&main_menu);
bt_shell_add_submenu(&advertise_menu);
bt_shell_add_submenu(&scan_menu);
diff --git a/src/shared/shell.c b/src/shared/shell.c
index e22d664..0878cad 100644
--- a/src/shared/shell.c
+++ b/src/shared/shell.c
return io;
}
-static GOptionEntry options[] = {
+static GOptionEntry main_options[] = {
{ "version", 'v', 0, G_OPTION_ARG_NONE, &option_version,
"Show version information and exit" },
{ NULL },
rl_callback_handler_install(NULL, rl_handler);
}
-void bt_shell_init(int *argc, char ***argv)
+void bt_shell_init(int *argc, char ***argv, GOptionEntry *options)
{
GOptionContext *context;
GError *error = NULL;
context = g_option_context_new(NULL);
- g_option_context_add_main_entries(context, options, NULL);
+ g_option_context_add_main_entries(context, main_options, NULL);
+ if (options)
+ g_option_context_add_main_entries(context, options, NULL);
if (g_option_context_parse(context, argc, argv, &error) == FALSE) {
if (error != NULL) {
diff --git a/src/shared/shell.h b/src/shared/shell.h
index 57b67cb..f2eb854 100644
--- a/src/shared/shell.h
+++ b/src/shared/shell.h
const struct bt_shell_menu_entry entries[];
};
-void bt_shell_init(int *argc, char ***argv);
+void bt_shell_init(int *argc, char ***argv, GOptionEntry *options);
void bt_shell_run(void);