mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Sascha Hauer <s.hauer@pengutronix.de>
To: barebox@lists.infradead.org
Subject: [PATCH 1/6] complete: Fix completion after options
Date: Mon, 19 May 2014 22:59:39 +0200	[thread overview]
Message-ID: <1400533184-668-2-git-send-email-s.hauer@pengutronix.de> (raw)
In-Reply-To: <1400533184-668-1-git-send-email-s.hauer@pengutronix.de>

the command specific complete callbacks only work when no
option is typed already. For example "devinfo <tab><tab>"
correctly completes the devices, but "devinfo -x <tab><tab>"
does nothing. That is because the options are passed to
the input string of the completion handlers. Skip the option
string by finding the last space in the input string. This
is not perfect since "devinfo -f<tab><tab>" still does not
work, but it's better than what we have now.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 common/complete.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/common/complete.c b/common/complete.c
index 9206ef0..368321f 100644
--- a/common/complete.c
+++ b/common/complete.c
@@ -277,11 +277,16 @@ static char* cmd_complete_lookup(struct string_list *sl, char *instr)
 	int len;
 	int ret = COMPLETE_END;
 	char *res = NULL;
+	char *t;
 
 	for_each_command(cmdtp) {
 		len = strlen(cmdtp->name);
 		if (!strncmp(instr, cmdtp->name, len) && instr[len] == ' ') {
 			instr += len + 1;
+			t = strrchr(instr, ' ');
+			if (t)
+				instr = t + 1;
+
 			if (cmdtp->complete) {
 				ret = cmdtp->complete(sl, instr);
 				res = instr;
-- 
2.0.0.rc0


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

  reply	other threads:[~2014-05-19 21:00 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-05-19 20:59 [PATCH] devicetree command changes Sascha Hauer
2014-05-19 20:59 ` Sascha Hauer [this message]
2014-05-19 20:59 ` [PATCH 2/6] complete: Add devicetree completion Sascha Hauer
2014-05-19 20:59 ` [PATCH 3/6] commands: add of_dump command Sascha Hauer
2014-05-21 13:17   ` Holger Schurig
2014-05-22  6:10     ` Sascha Hauer
2014-05-19 20:59 ` [PATCH 4/6] oftree: remove dump support Sascha Hauer
2014-05-20  8:01   ` Alexander Aring
2014-05-20  8:03     ` Alexander Aring
2014-05-20  9:08       ` Sascha Hauer
2014-05-19 20:59 ` [PATCH 5/6] of: Drop devicetree merge support Sascha Hauer
2014-05-20 15:08   ` Sebastian Hesselbarth
2014-05-21  6:13     ` Sascha Hauer
2014-05-21  6:35     ` Esben Haabendal
2014-05-21 12:39       ` Sascha Hauer
2014-05-21 13:24   ` Holger Schurig
2014-05-19 20:59 ` [PATCH 6/6] oftree command: make devicetree file optargs to -l/-s Sascha Hauer

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=1400533184-668-2-git-send-email-s.hauer@pengutronix.de \
    --to=s.hauer@pengutronix.de \
    --cc=barebox@lists.infradead.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