From: "Hugo Hörnquist" <hugo@lysator.liu.se>
To: guile-devel@gnu.org
Subject: Bash autocompletion for guild.
Date: Wed, 5 Jun 2019 20:27:26 +0200 [thread overview]
Message-ID: <20190605182726.GB3836@STATENSlaptop> (raw)
[-- Attachment #1: Type: text/plain, Size: 193 bytes --]
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
[-- Attachment #2: 0001-Add-bash_completion-for-guild.patch --]
[-- Type: text/plain, Size: 1612 bytes --]
From 25d545e25833e7c174bed8873f24ea525db0fc1c Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Hugo=20H=C3=B6rnquist?= <hugo@hornquist.se>
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
reply other threads:[~2019-06-05 18:27 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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
List information: https://www.gnu.org/software/guile/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190605182726.GB3836@STATENSlaptop \
--to=hugo@lysator.liu.se \
--cc=guile-devel@gnu.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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).