From patchwork Fri Jun 21 06:37:38 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wayne Xia X-Patchwork-Id: 253144 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 2C1882C013D for ; Fri, 21 Jun 2013 16:41:32 +1000 (EST) Received: from localhost ([::1]:38275 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Upv2I-0004ed-9D for incoming@patchwork.ozlabs.org; Fri, 21 Jun 2013 02:41:30 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40176) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Upv0V-0002Yc-Nz for qemu-devel@nongnu.org; Fri, 21 Jun 2013 02:39:41 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Upv0T-0004hh-JL for qemu-devel@nongnu.org; Fri, 21 Jun 2013 02:39:39 -0400 Received: from e28smtp08.in.ibm.com ([122.248.162.8]:40220) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Upv0S-0004hD-Tu for qemu-devel@nongnu.org; Fri, 21 Jun 2013 02:39:37 -0400 Received: from /spool/local by e28smtp08.in.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Fri, 21 Jun 2013 12:01:05 +0530 Received: from d28dlp02.in.ibm.com (9.184.220.127) by e28smtp08.in.ibm.com (192.168.1.138) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Fri, 21 Jun 2013 12:01:03 +0530 Received: from d28relay02.in.ibm.com (d28relay02.in.ibm.com [9.184.220.59]) by d28dlp02.in.ibm.com (Postfix) with ESMTP id BCADE3940053 for ; Fri, 21 Jun 2013 12:09:30 +0530 (IST) Received: from d28av04.in.ibm.com (d28av04.in.ibm.com [9.184.220.66]) by d28relay02.in.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id r5L6dZpT20578414 for ; Fri, 21 Jun 2013 12:09:35 +0530 Received: from d28av04.in.ibm.com (loopback [127.0.0.1]) by d28av04.in.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id r5L6dLGj032410 for ; Fri, 21 Jun 2013 16:39:22 +1000 Received: from RH63Wenchao (wenchaox.cn.ibm.com [9.115.122.50]) by d28av04.in.ibm.com (8.14.4/8.13.1/NCO v10.0 AVin) with ESMTP id r5L6biWh027133; Fri, 21 Jun 2013 16:39:19 +1000 From: Wenchao Xia To: qemu-devel@nongnu.org Date: Fri, 21 Jun 2013 14:37:38 +0800 Message-Id: <1371796658-15632-3-git-send-email-xiawenc@linux.vnet.ibm.com> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1371796658-15632-1-git-send-email-xiawenc@linux.vnet.ibm.com> References: <1371796658-15632-1-git-send-email-xiawenc@linux.vnet.ibm.com> X-TM-AS-MML: No X-Content-Scanned: Fidelis XPS MAILER x-cbid: 13062106-2000-0000-0000-00000C947BE0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x-2.6.x [generic] X-Received-From: 122.248.162.8 Cc: pbonzini@redhat.com, Wenchao Xia , armbru@redhat.com, lcapitulino@redhat.com Subject: [Qemu-devel] [PATCH 2/2] monitor: support sub commands in auto completion X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org This patch allow auot completion work normal in sub command case, "info block [DEVICE]" can auto complete now, by re-enter the completion function. Also, original "info" is treated as a special case, now it is treated as a sub command group, global variable info_cmds is not used any more. Signed-off-by: Wenchao Xia --- monitor.c | 12 ++++++------ 1 files changed, 6 insertions(+), 6 deletions(-) diff --git a/monitor.c b/monitor.c index bc60171..c706644 100644 --- a/monitor.c +++ b/monitor.c @@ -4180,6 +4180,11 @@ static void monitor_find_completion(Monitor *mon, goto cleanup; } + if (cmd->sub_table) { + return monitor_find_completion(mon, cmd->sub_table, + cmdline + strlen(cmd->name)); + } + ptype = next_arg_type(cmd->args_type); for(i = 0; i < nb_args - 2; i++) { if (*ptype != '\0') { @@ -4207,12 +4212,7 @@ static void monitor_find_completion(Monitor *mon, break; case 's': /* XXX: more generic ? */ - if (!strcmp(cmd->name, "info")) { - readline_set_completion_index(mon->rs, strlen(str)); - for(cmd = info_cmds; cmd->name != NULL; cmd++) { - cmd_completion(mon, str, cmd->name); - } - } else if (!strcmp(cmd->name, "sendkey")) { + if (!strcmp(cmd->name, "sendkey")) { char *sep = strrchr(str, '-'); if (sep) str = sep + 1;