2019-08-17 06:39:20

by Ronan Pigott

[permalink] [raw]
Subject: [PATCH BlueZ v2 1/4] client/main: add help option for available args

From: Ronan Pigott <[email protected]>

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.

---
client/main.c | 8 ++++++++
1 file changed, 8 insertions(+)

diff --git a/client/main.c b/client/main.c
index 578b3c7c3..0f810901a 100644
--- a/client/main.c
+++ b/client/main.c
@@ -800,6 +800,14 @@ 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)
--
2.22.1