From mboxrd@z Thu Jan 1 00:00:00 1970 From: Philip Oakley Subject: [PATCH 05/13] Help.c: add list_common_guides_help() function Date: Sat, 23 Feb 2013 23:05:53 +0000 Message-ID: <1361660761-1932-6-git-send-email-philipoakley@iee.org> References: <1361660761-1932-1-git-send-email-philipoakley@iee.org> To: GitList X-From: git-owner@vger.kernel.org Sun Feb 24 00:06:27 2013 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 1U9OAY-0002d7-8o for gcvg-git-2@plane.gmane.org; Sun, 24 Feb 2013 00:06:14 +0100 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1759369Ab3BWXFm (ORCPT ); Sat, 23 Feb 2013 18:05:42 -0500 Received: from out1.ip04ir2.opaltelecom.net ([62.24.128.240]:3202 "EHLO out1.ip04ir2.opaltelecom.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1759352Ab3BWXFg (ORCPT ); Sat, 23 Feb 2013 18:05:36 -0500 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: Av8EABpKKVFZ8rke/2dsb2JhbABFwVGBCBdzgiABBVYzCEk5HgYTiBe+eY8Vg0ADoB6HBIMH X-IronPort-AV: E=Sophos;i="4.84,724,1355097600"; d="scan'208";a="400995028" Received: from host-89-242-185-30.as13285.net (HELO localhost) ([89.242.185.30]) by out1.ip04ir2.opaltelecom.net with ESMTP; 23 Feb 2013 23:05:34 +0000 X-Mailer: git-send-email 1.8.1.msysgit.1 In-Reply-To: <1361660761-1932-1-git-send-email-philipoakley@iee.org> Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Archived-At: Re-use list_common_cmds_help but simply change the array name. Candidate for future refactoring to pass a pointer to the array. Do not list User-manual and Everday Git which not follow the naming convention, nor gitrepository-layout which doesn't fit within the name field size Signed-off-by: Philip Oakley --- builtin/help.c | 1 + common-guides.h | 12 ++++++++++++ help.c | 18 ++++++++++++++++++ help.h | 1 + 4 files changed, 32 insertions(+) create mode 100644 common-guides.h diff --git a/builtin/help.c b/builtin/help.c index 699e679..b0746af 100644 --- a/builtin/help.c +++ b/builtin/help.c @@ -434,6 +434,7 @@ int cmd_help(int argc, const char **argv, const char *prefix) if (!show_guides) return 0; } if (show_guides) { + list_common_guides_help(); return 0; } if (!argv[0]) { diff --git a/common-guides.h b/common-guides.h new file mode 100644 index 0000000..a8ad8d1 --- /dev/null +++ b/common-guides.h @@ -0,0 +1,12 @@ +/* Automatically generated by ./generate-guidelist.sh */ +/* re-use struct cmdname_help in common-commands.h */ + +static struct cmdname_help common_guides[] = { + {"attributes", "defining attributes per path"}, + {"glossary", "A GIT Glossary"}, + {"ignore", "Specifies intentionally untracked files to ignore"}, + {"modules", "defining submodule properties"}, + {"revisions", "specifying revisions and ranges for git"}, + {"tutorial", "A tutorial introduction to git (for version 1.5.1 or newer)"}, + {"workflows", "An overview of recommended workflows with git"}, +}; diff --git a/help.c b/help.c index 1c0e17d..94df446 100644 --- a/help.c +++ b/help.c @@ -4,6 +4,7 @@ #include "levenshtein.h" #include "help.h" #include "common-cmds.h" +#include "common-guides.h" #include "string-list.h" #include "column.h" #include "version.h" @@ -240,6 +241,23 @@ void list_common_cmds_help(void) } } +void list_common_guides_help(void) +{ + int i, longest = 0; + + for (i = 0; i < ARRAY_SIZE(common_guides); i++) { + if (longest < strlen(common_guides[i].name)) + longest = strlen(common_guides[i].name); + } + + puts(_("The common Git guides are:")); + for (i = 0; i < ARRAY_SIZE(common_guides); i++) { + printf(" %s ", common_guides[i].name); + mput_char(' ', longest - strlen(common_guides[i].name)); + puts(_(common_guides[i].help)); + } +} + int is_in_cmdlist(struct cmdnames *c, const char *s) { int i; diff --git a/help.h b/help.h index 0ae5a12..4ae1fd7 100644 --- a/help.h +++ b/help.h @@ -17,6 +17,7 @@ static inline void mput_char(char c, unsigned int num) } extern void list_common_cmds_help(void); +extern void list_common_guides_help(void); extern const char *help_unknown_cmd(const char *cmd); extern void load_command_list(const char *prefix, struct cmdnames *main_cmds, -- 1.8.1.msysgit.1