client/main: add help option for available args
authorRonan Pigott <rpigott@berkeley.edu>
Sat, 17 Aug 2019 06:34:49 +0000 (23:34 -0700)
committerhimanshu <h.himanshu@samsung.com>
Tue, 11 Feb 2020 08:57:47 +0000 (14:27 +0530)
This option exists to facilitate external completion of commands that
have specially defined arguments. It effectively adds two new commands
to bluetoothctl with the following output:

$ bluetoothctl agent help
on
off
DisplayOnly
DisplayYesNo
KeyboardDisplay
KeyboardOnly
NoInputNoOutput

$ bluetoothctl advertise help
on
off
peripheral
broadcast

Shell completion scripts can then parse this output to provide
completions for those commands.

Change-Id: Ia431ea11d7a1cb344b512f0180bd0ebac0754567
Signed-off-by: himanshu <h.himanshu@samsung.com>
client/main.c

index a3206be..c530dc9 100644 (file)
@@ -799,6 +799,13 @@ static gboolean parse_argument(int argc, char *argv[], const char **arg_table,
 {
        const char **opt;
 
+       if (!strcmp(argv[1], "help")) {
+               for (opt = arg_table; opt && *opt; opt++)
+                       bt_shell_printf("%s\n", *opt);
+               bt_shell_noninteractive_quit(EXIT_SUCCESS);
+               return FALSE;
+       }
+
        if (!strcmp(argv[1], "on") || !strcmp(argv[1], "yes")) {
                *value = TRUE;
                if (option)