summaryrefslogtreecommitdiff
path: root/mesh/main.c
diff options
context:
space:
mode:
authorLuiz Augusto von Dentz <luiz.von.dentz@intel.com>2017-12-08 08:52:54 -0200
committerJohan Hedberg <johan.hedberg@intel.com>2017-12-08 13:06:19 +0200
commit7c16c4044d1f8f7e667a5c4e4e8f72b6627bf115 (patch)
tree4eb26e004732d7cf10ec315641a1c6cf4dcff7e5 /mesh/main.c
parentab41d6df80aa49e87c81b1a6383f9540fcc2d257 (diff)
downloadbluez-7c16c4044d1f8f7e667a5c4e4e8f72b6627bf115.tar.gz
shell: Add bt_shell_opt
Make use of struct option and getopt_long to parse the options given.
Diffstat (limited to 'mesh/main.c')
-rw-r--r--mesh/main.c25
1 files changed, 20 insertions, 5 deletions
diff --git a/mesh/main.c b/mesh/main.c
index 05841363f..4d63c5751 100644
--- a/mesh/main.c
+++ b/mesh/main.c
@@ -1925,10 +1925,25 @@ static const struct bt_shell_menu main_menu = {
static const char *mesh_config_dir;
-static GOptionEntry options[] = {
- { "config", 'c', 0, G_OPTION_ARG_STRING, &mesh_config_dir,
- "Read local mesh config JSON files from <directory>" },
- { NULL },
+static const struct option options[] = {
+ { "config", required_argument, 0, 'c' },
+ { 0, 0, 0, 0 }
+};
+
+static const char **optargs[] = {
+ &mesh_config_dir
+};
+
+static const char *help[] = {
+ "Read local mesh config JSON files from <directory>"
+};
+
+static const struct bt_shell_opt opt = {
+ .options = options,
+ .optno = sizeof(options) / sizeof(struct option),
+ .optstr = "c:",
+ .optarg = optargs,
+ .help = help,
};
static void client_ready(GDBusClient *client, void *user_data)
@@ -1942,7 +1957,7 @@ int main(int argc, char *argv[])
int len;
int extra;
- bt_shell_init(&argc, &argv, options);
+ bt_shell_init(argc, argv, &opt);
bt_shell_set_menu(&main_menu);
bt_shell_set_prompt(PROMPT_OFF);