Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp1390219ybl; Fri, 16 Aug 2019 14:13:39 -0700 (PDT) X-Google-Smtp-Source: APXvYqwwLJ3CCppAEfWZYmMEL6s5i6neZNumDErFU2hcKxaZmC1Yv1+0JyboUXEQmKNluLDTvefs X-Received: by 2002:a17:90a:374a:: with SMTP id u68mr9071352pjb.4.1565990019291; Fri, 16 Aug 2019 14:13:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565990019; cv=none; d=google.com; s=arc-20160816; b=L8I1cPrPek3T1/eIzyPzqWFxmSIDA7F0f9e8SUP29nKcuCdJoqhp2k42nQChFWx1Wh NgRi2KjH2hHGuGNVQMnNkNF4x76+wpt8Vf9rb+c6JPs/tLvb1FLpc3m9Lr6I+0qdwV2J lWmvRbBbDDcQkbp5J75bXB0wEHq82aJsF8S1/v8CA5QtjQ3hg65yBj9f/7sgXwfMiuv+ +FDWvlgQDzUIk4itHEvs8sQIKY2jUKwc5rN3dc9ZgGJpykXno7DsRaBH9HkZxtFigTCe 4ibahfN/4V32uD5hJCV2ZBGpplO4kphPK3Hfu810gLW09DNBtZUqqFkk8ODrzFk4ZfTr 4ETg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:to:from:subject:date :in-reply-to:content-transfer-encoding:dkim-signature; bh=jg3TY6Ppod1XYmpYlM2FSu8pu8e3ChdrZXQNJygjk7g=; b=U+73MIb3WWSYN+YIwNUgSpdXLX/mEdd1V0eSy8GPgxg1HJF2exoyS/Vpqb+Jqtg4jC +fxxBTFWe+p42HaMPOxqq/9aYzIZTUXb5HR7kbgIkerYa/JhQiB8KBAbMN7q05xs1wQb bIuQ2V7U9DthyyGKF8xTlE+eMdQ+KIN/lv3eU9Twj9+8x58lBL6i6lSfDC4VXblLaPn/ VEH5otXwL+9UkjHEqhTLhndbzuYVnsn6Huj9WYUcqDV/O9iqRPoBUbdIMwe+Jt90NPBH zF4fEHGLxPYdh1rsRvwbdNIF1aX0gmw1vfij8FexuToOzwuW+r4TyDPhP04uI/fWLiPy W3Dw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=Ydxv64tJ; spf=pass (google.com: best guess record for domain of linux-bluetooth-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a9si4751891plm.295.2019.08.16.14.13.09; Fri, 16 Aug 2019 14:13:39 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-bluetooth-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=Ydxv64tJ; spf=pass (google.com: best guess record for domain of linux-bluetooth-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727572AbfHPVMY (ORCPT + 99 others); Fri, 16 Aug 2019 17:12:24 -0400 Received: from mail-pl1-f193.google.com ([209.85.214.193]:41110 "EHLO mail-pl1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727548AbfHPVMX (ORCPT ); Fri, 16 Aug 2019 17:12:23 -0400 Received: by mail-pl1-f193.google.com with SMTP id m9so2913023pls.8 for ; Fri, 16 Aug 2019 14:12:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=content-transfer-encoding:in-reply-to:date:subject:from:to :message-id; bh=jg3TY6Ppod1XYmpYlM2FSu8pu8e3ChdrZXQNJygjk7g=; b=Ydxv64tJRx0x4hoMzzj4WBlvy/DYizR0NhceXoDnFqUNleQau0Hjf5eX0aviGCh56v QSrRYkjmyk3kFV8u8uVWvx8ZBKXFEoG5rdLQbzSK2XmR9hmodq2TFN+MKKGifePDdf9Q kEZIqi6IU+mPH/MdnMuuQ0Q7RvFYC61qcRhEBpml47sFU8RskBwRcUj1lCYAKruES1Ke Mv/wL6JfPBcj6Lxzo36MfFM0VPih74PQVXq0sARBjNNI3R0u7eee07Y17L2gphoDLsfv Gf3byomFzKfI/y/87bfL+wNypcFlnADrSs3d+n8Z3wO0PCW3qc3w9cLXzUpurGtGj2g+ SczQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:content-transfer-encoding:in-reply-to:date :subject:from:to:message-id; bh=jg3TY6Ppod1XYmpYlM2FSu8pu8e3ChdrZXQNJygjk7g=; b=NJ8C487B1a6t8HUU1q3IdWlgGTah8T+W9EYGOwxN+a78+gJAhyygaWaY5793nyhBXs ioit3mVF0oWhxpdtcyNypEtEKbtskAT2UKXLXmSug6FpkXlwadH3owZScOwcbTkj/AiH ONW8+l6p9yilVOAJS725ZPX3UhYBUhdb68yif8wLah0PsYugcrHoRS4wf7oCPwDoeSgj J9k6kCZHkM46VcRiqQAlZGZll3ZcMkOLOtY3GA+YfEk3whJg3pVMyDHaCCM0SpUV7g0/ UAVdZ2U2dQjNwkHo4RIb82wDTbNDtxvndx0tPnYGuBSXE4P2xw3iFiyugxrlUx9doYyg vjiA== X-Gm-Message-State: APjAAAVOsgPJwu0KXDLS5pZST5ODrPJ/ZVt8EX08fD0MxM9t92oeWopb tHlq7MV9G67Vk+T6hCyVucuMTnc= X-Received: by 2002:a17:902:6b07:: with SMTP id o7mr10869505plk.180.1565989942791; Fri, 16 Aug 2019 14:12:22 -0700 (PDT) Received: from localhost ([2600:8800:1e00:242:3550:edee:2708:4ad0]) by smtp.gmail.com with ESMTPSA id v184sm5991213pgd.34.2019.08.16.14.12.21 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 16 Aug 2019 14:12:22 -0700 (PDT) Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=UTF-8 In-Reply-To: Date: Fri, 16 Aug 2019 14:12:21 -0700 Subject: Fwd: Re: [PATCH BlueZ 1/3] client/main: add help option for available args From: "Ronan Pigott" To: Message-Id: Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org 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. >=20 > > + if (!strcmp(argv[1], "help")) { > > + for (opt =3D 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 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.