Diff between cb1c2622faed53a2612ec8bdffab5b0f72707696 and 5e7ad41d088fb5d169256df61bc93ce33bc0fbef

Changed Files

File Additions Deletions Status
client/agent.c +2 -0 modified
client/main.c +1 -17 modified
src/shared/shell.c +5 -3 modified
src/shared/shell.h +1 -1 modified

Full Patch

diff --git a/client/agent.c b/client/agent.c
index e8ca4dd..70c3248 100644
--- a/client/agent.c
+++ b/client/agent.c
@@ -31,6 +31,8 @@
 #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
@@ -2369,27 +2369,11 @@ static void client_ready(GDBusClient *client, void *user_data)
 
 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
@@ -654,7 +654,7 @@ static struct io *setup_signalfd(void)
 	return io;
 }
 
-static GOptionEntry options[] = {
+static GOptionEntry main_options[] = {
 	{ "version", 'v', 0, G_OPTION_ARG_NONE, &option_version,
 				"Show version information and exit" },
 	{ NULL },
@@ -669,13 +669,15 @@ static void rl_init(void)
 	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
@@ -50,7 +50,7 @@ struct bt_shell_menu {
 	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);