From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Hugo =?utf-8?Q?H=C3=B6rnquist?= Newsgroups: gmane.lisp.guile.devel Subject: Bash autocompletion for guild. Date: Wed, 5 Jun 2019 20:27:26 +0200 Message-ID: <20190605182726.GB3836@STATENSlaptop> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="C7zPtVaVf+AK4Oqc" Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="270023"; mail-complaints-to="usenet@blaine.gmane.org" User-Agent: Mutt/1.12.0 (2019-05-25) To: guile-devel@gnu.org Original-X-From: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Wed Jun 05 20:38:40 2019 Return-path: Envelope-to: guile-devel@m.gmane.org Original-Received: from lists.gnu.org ([209.51.188.17]) by blaine.gmane.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hYao2-00186N-8m for guile-devel@m.gmane.org; Wed, 05 Jun 2019 20:38:38 +0200 Original-Received: from localhost ([127.0.0.1]:48257 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hYao1-0003OE-6r for guile-devel@m.gmane.org; Wed, 05 Jun 2019 14:38:37 -0400 Original-Received: from eggs.gnu.org ([209.51.188.92]:45637) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hYamu-0002dr-Sa for guile-devel@gnu.org; Wed, 05 Jun 2019 14:37:29 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hYadS-0002KB-8Z for guile-devel@gnu.org; Wed, 05 Jun 2019 14:27:43 -0400 Original-Received: from mail.lysator.liu.se ([2001:6b0:17:f0a0::3]:47997) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hYadS-00025d-0E for guile-devel@gnu.org; Wed, 05 Jun 2019 14:27:42 -0400 Original-Received: from mail.lysator.liu.se (localhost [127.0.0.1]) by mail.lysator.liu.se (Postfix) with ESMTP id 28C9140025 for ; Wed, 5 Jun 2019 20:27:35 +0200 (CEST) Original-Received: by mail.lysator.liu.se (Postfix, from userid 1004) id 12EC040027; Wed, 5 Jun 2019 20:27:34 +0200 (CEST) Original-Received: from STATENSlaptop (h-109-128.A163.priv.bahnhof.se [94.254.109.128]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.lysator.liu.se (Postfix) with ESMTPSA id 2880240025; Wed, 5 Jun 2019 20:27:33 +0200 (CEST) Content-Disposition: inline X-Virus-Scanned: ClamAV using ClamSMTP X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2001:6b0:17:f0a0::3 X-BeenThere: guile-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: "Developers list for Guile, the GNU extensibility library" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Original-Sender: "guile-devel" Xref: news.gmane.org gmane.lisp.guile.devel:19940 Archived-At: --C7zPtVaVf+AK4Oqc Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Hi! I added basic bash autocompletion for guild commands. Unfortunately it's only for the first word, since flags for the individual commands aren't given in on a standardized form. -- hugo --C7zPtVaVf+AK4Oqc Content-Type: text/plain; charset=utf-8 Content-Disposition: attachment; filename="0001-Add-bash_completion-for-guild.patch" >From 25d545e25833e7c174bed8873f24ea525db0fc1c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hugo=20H=C3=B6rnquist?= Date: Wed, 5 Jun 2019 17:14:16 +0200 Subject: [PATCH] Add bash_completion for guild. --- bash_completion | 5 +++++ module/scripts/help.scm | 9 +++++++++ 2 files changed, 14 insertions(+) create mode 100644 bash_completion diff --git a/bash_completion b/bash_completion new file mode 100644 index 000000000..a8e3361bc --- /dev/null +++ b/bash_completion @@ -0,0 +1,5 @@ +_guild() { + COMPREPLY=( $(guild help --complete $2) ) +} + +complete -F _guild -f guild diff --git a/module/scripts/help.scm b/module/scripts/help.scm index 34400db3a..b8d544e8b 100644 --- a/module/scripts/help.scm +++ b/module/scripts/help.scm @@ -165,6 +165,10 @@ For complete documentation, run: info '(guile)Using Guile Tools' (format #t "No documentation found for command \"~a\".\n" (module-command-name mod))))) +(define (completions prefix) + (filter (lambda (s) (string-prefix? prefix s)) + (find-submodules '(scripts)))) + (define %mod (current-module)) (define (main . args) (cond @@ -183,6 +187,11 @@ For complete documentation, run: info '(guile)Using Guile Tools' (else (format #t "No command named \"~a\".\n" name) (exit 1))))) + ((equal? (car args) "--complete") + (unless (null? (cdr args)) + (for-each (lambda (completion) + (display completion) (display " ")) + (completions (cadr args))))) (else (show-help %mod (current-error-port)) (exit 1)))) -- 2.21.0 --C7zPtVaVf+AK4Oqc--