From mboxrd@z Thu Jan 1 00:00:00 1970 From: =?UTF-8?q?S=C3=A9bastien=20Guimmara?= Subject: [PATCH v5 1/6] generate-cmdlist: parse common group commands Date: Sat, 9 May 2015 19:17:31 +0200 Message-ID: <1431191856-10949-2-git-send-email-sebastien.guimmara@gmail.com> References: <1431191856-10949-1-git-send-email-sebastien.guimmara@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: QUOTED-PRINTABLE Cc: =?UTF-8?q?S=C3=A9bastien=20Guimmara?= , Eric Sunshine To: git@vger.kernel.org X-From: git-owner@vger.kernel.org Sat May 09 19:18:28 2015 Return-path: Envelope-to: gcvg-git-2@plane.gmane.org Received: from vger.kernel.org ([209.132.180.67]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1Yr8OR-0000WU-Fr for gcvg-git-2@plane.gmane.org; Sat, 09 May 2015 19:18:27 +0200 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751201AbbEIRSU convert rfc822-to-quoted-printable (ORCPT ); Sat, 9 May 2015 13:18:20 -0400 Received: from mail-wg0-f48.google.com ([74.125.82.48]:35058 "EHLO mail-wg0-f48.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750994AbbEIRST (ORCPT ); Sat, 9 May 2015 13:18:19 -0400 Received: by wgyo15 with SMTP id o15so96427931wgy.2 for ; Sat, 09 May 2015 10:18:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-type:content-transfer-encoding; bh=jE9hsM2kvD9cPhg8Z4lvxMujez3rPs6PeBTUcfjy5Xo=; b=uQcNfpC/+T7QGV4fVW1hWthHdIjDi3OYZdRi1YUf0ru8ljU72QnjClF31nAm8eB9G6 8OaYi/Z+cSksioLzm2OZg9d9fy3rwnazPX627jjXcTDlOpRSU1WQAHg9GeRtGwmzfZyu RvgRBiRaf6bQe0LE/DreuSZunBD6QXkTsP2QAtqIPipPZ1O3hrmpVNxGi/2Rc2qtNgD6 mXSAUwLshjHR+8AjLKFnipjnQxMtF8sHe3zvNUIqYkEuVRNQZxpppmQnHCQC6l1qG3dm D12x1VVMzXSe4/8pT79WPoT8Kga3dyXuuwJDGQgR06o3cK96LVmWoSev9Iq0bggmTEJu ZZ3Q== X-Received: by 10.180.98.230 with SMTP id el6mr5992964wib.16.1431191898216; Sat, 09 May 2015 10:18:18 -0700 (PDT) Received: from localhost.localdomain (bd231-1-88-176-208-17.fbx.proxad.net. [88.176.208.17]) by mx.google.com with ESMTPSA id fo7sm4710675wic.1.2015.05.09.10.18.16 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sat, 09 May 2015 10:18:17 -0700 (PDT) X-Mailer: git-send-email 2.4.0 In-Reply-To: <1431191856-10949-1-git-send-email-sebastien.guimmara@gmail.com> Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Archived-At: Parse the [common] block to create the array of group descriptions: static char *common_cmd_groups[] =3D { N_("start a working area (see also: git help tutorial)"), N_("work on the current change (see also: git help everyday)"), N_("examine the history and state (see also: git help revisions)"), N_("grow, mark and tweak your history"), N_("collaborate (see also: git help workflows)"), }; then map each element of common_cmds[] to a group via its index: static struct cmdname_help common_cmds[] =3D { {"add", N_("Add file contents to the index"), 1}, {"branch", N_("List, create, or delete branches"), 4}, {"checkout", N_("Checkout a branch or paths to the ..."), 4}, {"clone", N_("Clone a repository into a new directory"), 0}, {"commit", N_("Record changes to the repository"), 4}, ... }; so that 'git help' can print those commands grouped by theme. Only commands tagged with an attribute from [common] are emitted to common_cmds[]. [commit message by S=C3=A9bastien Guimmara ] Signed-off-by: Eric Sunshine --- generate-cmdlist.awk | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 generate-cmdlist.awk diff --git a/generate-cmdlist.awk b/generate-cmdlist.awk new file mode 100644 index 0000000..cbaac88 --- /dev/null +++ b/generate-cmdlist.awk @@ -0,0 +1,38 @@ +BEGIN { + print "/* Automatically generated by generate-cmdlist.awk */\n" + print "struct cmdname_help {" + print "\tchar name[16];" + print "\tchar help[80];" + print "\tunsigned char group;" + print "};\n" + print "static char *common_cmd_groups[] =3D {" +} +/^#/ || /^[ ]*$/ { next } +state =3D=3D 2 { + for (i =3D 2; i <=3D NF; i++) + if (grp[$i]) { + f =3D "Documentation/"$1".txt" + while (getline s 0) + if (match(s, $1" - ")) { + t =3D substr(s, length($1" - ") + 1) + break + } + close(f) + printf "\t{\"%s\", N_(\"%s\"), %s},\n", + substr($1, length("git-") + 1), t, grp[$i] - 1 + break + } +} +/\[commands\]/ { + print "};\n\nstatic struct cmdname_help common_cmds[] =3D {" + state =3D 2 +} +state =3D=3D 1 { + grp[$1] =3D ++n + sub($1"[ ][ ]*", "") + printf "\tN_(\"%s\"),\n", $0 +} +/\[common\]/ { + state =3D 1 +} +END { print "};" } --=20 2.4.0