builtin/help.c: add list_common_guides_help() function
This implements what "help -g" introduced in the previous step does. Signed-off-by: Philip Oakley <philipoakley@iee.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Philip Oakley committed
Apr 2, 2013 at 23:39 UTC
002b726a400a1dea16c0b59ae61527a1e55799fb
1 file changed
+33
-3
builtin/help.c
+33
-3
@@ -415,6 +415,37 @@ static void show_html_page(const char *git_cmd)
415
open_html(page_path.buf);
416
}
417
418
+static struct {
419
+ const char *name;
420
+ const char *help;
421
+} common_guides[] = {
422
+ { "attributes", "Defining attributes per path" },
423
+ { "glossary", "A Git glossary" },
424
+ { "ignore", "Specifies intentionally untracked files to ignore" },
425
+ { "modules", "Defining submodule properties" },
426
+ { "revisions", "Specifying revisions and ranges for Git" },
427
+ { "tutorial", "A tutorial introduction to Git (for version 1.5.1 or newer)" },
428
+ { "workflows", "An overview of recommended workflows with Git"},
429
+};
430
+
431
+static void list_common_guides_help(void)
432
+{
433
+ int i, longest = 0;
434
+
435
+ for (i = 0; i < ARRAY_SIZE(common_guides); i++) {
436
+ if (longest < strlen(common_guides[i].name))
437
+ longest = strlen(common_guides[i].name);
438
+ }
439
+
440
+ puts(_("The common Git guides are:\n"));
441
+ for (i = 0; i < ARRAY_SIZE(common_guides); i++) {
442
+ printf(" %s ", common_guides[i].name);
443
+ mput_char(' ', longest - strlen(common_guides[i].name));
444
+ puts(_(common_guides[i].help));
445
+ }
446
+ putchar('\n');
447
+}
448
+
449
int cmd_help(int argc, const char **argv, const char *prefix)
450
{
451
int nongit;
@@ -432,9 +463,8 @@ int cmd_help(int argc, const char **argv, const char *prefix)
463
list_commands(colopts, &main_cmds, &other_cmds);
464
}
465
435
- if (show_guides) {
436
- /* do action - next patch */
437
- }
466
+ if (show_guides)
467
+ list_common_guides_help();
468
469
if (show_all || show_guides) {
470
printf("%s\n", _(git_more_info_string));