diff options
author | Junio C Hamano <gitster@pobox.com> | 2015-06-01 12:45:18 -0700 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2015-06-01 12:45:19 -0700 |
commit | 6dec263333417738528089834bd8cda72017aa31 (patch) | |
tree | 70e67708b1100262c98206130af057cc0b137fa6 /generate-cmdlist.perl | |
parent | abcbafedbfbd5994ad604bab141c0ba18f5a19df (diff) | |
parent | 224147704a3696d396dae005c280f7a25de407c7 (diff) | |
download | git-6dec263333417738528089834bd8cda72017aa31.tar.gz git-6dec263333417738528089834bd8cda72017aa31.tar.xz |
Merge branch 'sg/help-group'
Group list of commands shown by "git help" along the workflow
elements to help early learners.
* sg/help-group:
help: respect new common command grouping
command-list.txt: drop the "common" tag
generate-cmdlist: parse common group commands
command-list.txt: add the common groups block
command-list: prepare machinery for upcoming "common groups" section
Diffstat (limited to 'generate-cmdlist.perl')
-rwxr-xr-x | generate-cmdlist.perl | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/generate-cmdlist.perl b/generate-cmdlist.perl new file mode 100755 index 000000000..31516e36a --- /dev/null +++ b/generate-cmdlist.perl @@ -0,0 +1,50 @@ +#!/usr/bin/perl +use strict; +use warnings; + +print <<"EOT"; +/* Automatically generated by $0 */ + +struct cmdname_help { + char name[16]; + char help[80]; + unsigned char group; +}; + +static char *common_cmd_groups[] = { +EOT + +my $n = 0; +my %grp; +while (<>) { + last if /^### command list/; + next if (1../^### common groups/) || /^#/ || /^\s*$/; + chop; + my ($k, $v) = split ' ', $_, 2; + $grp{$k} = $n++; + print "\tN_(\"$v\"),\n"; +} + +print "};\n\nstatic struct cmdname_help common_cmds[] = {\n"; + +while (<>) { + next if /^#/ || /^\s*$/; + my @tags = split; + my $cmd = shift @tags; + for my $t (@tags) { + if (exists $grp{$t}) { + my $s; + open my $f, '<', "Documentation/$cmd.txt" or die; + while (<$f>) { + ($s) = /^$cmd - (.+)$/; + last if $s; + } + close $f; + $cmd =~ s/^git-//; + print "\t{\"$cmd\", N_(\"$s\"), $grp{$t}},\n"; + last; + } + } +} + +print "};\n"; |