public inbox for linux-bluetooth@vger.kernel.org
 help / color / mirror / Atom feed
From: "Ronan Pigott" <rpigott314@gmail.com>
To: <linux-bluetooth@vger.kernel.org>
Subject: Fwd: Re: [PATCH BlueZ 1/3] client/main: add help option for available args
Date: Fri, 16 Aug 2019 14:12:21 -0700	[thread overview]
Message-ID: <BWBD3RE9KDV9.PK2ODM7IZII9@rxps> (raw)
In-Reply-To: <BWBCB7VTY8ZD.2GSGD0H9H00LN@rxps>

On Fri Aug 16, 2019 at 2:29 PM Luiz Augusto von Dentz wrote:
> Can you a description of what the changes does, perhaps a sample when
> uses in some command.
> 
> > +       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;
> > +       }

I added the help option to parse_argument so that when the argument
value is "help", the result is to print a newline separated list
of the arg_table containing the other valid arguments. Now
the user gets the following output for the following commands:

$ bluetoothctl agent help
on
off
DisplayOnly
DisplayYesNo
KeyboardDisplay
KeyboardOnly
NoInputNoOutput

$ bluetoothctl advertise help
on
off
peripheral
broadcast

Only agent_arguments[] and ad_arguments[] are defined in client/main.c,
so these are effecively the only new commands. The completion script
can parse the output of `bluetoothctl agent help` and `bluetoothctl
advertise help` to complete those arguments.

Additionally, other commands now don't complain that "help" is invalid,
but otherwise have no output at all. However, I don't think there is a
need to make "help" available in more contexts.

Instead for commands that take a device (similar for controller),
I chose to parse the output of `bluetoothctl devices` to take
advantage of zsh's verbosity in completion menus. Now when completing
such commands the user can get more information than is immediately
available in the interactive shell.

e.g. I am presented with a menu with descriptions like so:

$ bluetoothctl connect <TAB>
04:52:C7:0C:D4:A7  -- Bose QuietComfort 35
40:4E:36:D9:8F:28  -- Pixel 2
A4:38:CC:20:5D:E0  -- Pro Controller

This convenient menu was my original motivation for the zsh completions,
as it makes the connect/disconnect commands much more convenient to use.

           reply	other threads:[~2019-08-16 21:12 UTC|newest]

Thread overview: expand[flat|nested]  mbox.gz  Atom feed
 [parent not found: <BWBCB7VTY8ZD.2GSGD0H9H00LN@rxps>]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=BWBD3RE9KDV9.PK2ODM7IZII9@rxps \
    --to=rpigott314@gmail.com \
    --cc=linux-bluetooth@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox