1#!/usr/bin/perl -w
2
3use File::Compare qw(compare);
4
5sub format_one {
6 my ($out, $name) = @_;
7 my ($state, $description);
8 $state = 0;
9 open I, '<', "$name.txt" or die "No such file $name.txt";
10 while (<I>) {
11 if (/^NAME$/) {
12 $state = 1;
13 next;
14 }
15 if ($state == 1 && /^----$/) {
16 $state = 2;
17 next;
18 }
19 next if ($state != 2);
20 chomp;
21 $description = $_;
22 last;
23 }
24 close I;
25 if (!defined $description) {
26 die "No description found in $name.txt";
27 }
28 if (my ($verify_name, $text) = ($description =~ /^($name) - (.*)/)) {
29 print $out "gitlink:$name\[1\]::\n";
30 print $out "\t$text.\n\n";
31 }
32 else {
33 die "Description does not match $name: $description";
34 }
35}
36
37my %cmds = ();
38while (<DATA>) {
39 next if /^#/;
40
41 chomp;
42 my ($name, $cat) = /^(\S+)\s+(.*)$/;
43 push @{$cmds{$cat}}, $name;
44}
45
46for my $cat (qw(ancillaryinterrogators
47 ancillarymanipulators
48 mainporcelain
49 plumbinginterrogators
50 plumbingmanipulators
51 synchingrepositories
52 foreignscminterface
53 purehelpers
54 synchelpers)) {
55 my $out = "cmds-$cat.txt";
56 open O, '>', "$out+" or die "Cannot open output file $out+";
57 for (@{$cmds{$cat}}) {
58 format_one(\*O, $_);
59 }
60 close O;
61
62 if (-f "$out" && compare("$out", "$out+") == 0) {
63 unlink "$out+";
64 }
65 else {
66 print STDERR "$out\n";
67 rename "$out+", "$out";
68 }
69}
70
71__DATA__
72git-add mainporcelain
73git-am mainporcelain
74git-annotate ancillaryinterrogators
75git-apply plumbingmanipulators
76git-archimport foreignscminterface
77git-archive mainporcelain
78git-bisect mainporcelain
79git-blame ancillaryinterrogators
80git-branch mainporcelain
81git-bundle mainporcelain
82git-cat-file plumbinginterrogators
83git-checkout-index plumbingmanipulators
84git-checkout mainporcelain
85git-check-attr purehelpers
86git-check-ref-format purehelpers
87git-cherry ancillaryinterrogators
88git-cherry-pick mainporcelain
89git-citool mainporcelain
90git-clean mainporcelain
91git-clone mainporcelain
92git-commit mainporcelain
93git-commit-tree plumbingmanipulators
94git-convert-objects ancillarymanipulators
95git-count-objects ancillaryinterrogators
96git-cvsexportcommit foreignscminterface
97git-cvsimport foreignscminterface
98git-cvsserver foreignscminterface
99git-daemon synchingrepositories
100git-describe mainporcelain
101git-diff-files plumbinginterrogators
102git-diff-index plumbinginterrogators
103git-diff mainporcelain
104git-diff-tree plumbinginterrogators
105git-fast-import ancillarymanipulators
106git-fetch mainporcelain
107git-fetch-pack synchingrepositories
108git-fmt-merge-msg purehelpers
109git-for-each-ref plumbinginterrogators
110git-format-patch mainporcelain
111git-fsck ancillaryinterrogators
112git-gc mainporcelain
113git-get-tar-commit-id ancillaryinterrogators
114git-grep mainporcelain
115git-gui mainporcelain
116git-hash-object plumbingmanipulators
117git-http-fetch synchelpers
118git-http-push synchelpers
119git-imap-send foreignscminterface
120git-index-pack plumbingmanipulators
121git-init mainporcelain
122git-instaweb ancillaryinterrogators
123gitk mainporcelain
124git-local-fetch synchingrepositories
125git-log mainporcelain
126git-lost-found ancillarymanipulators
127git-ls-files plumbinginterrogators
128git-ls-remote plumbinginterrogators
129git-ls-tree plumbinginterrogators
130git-mailinfo purehelpers
131git-mailsplit purehelpers
132git-merge-base plumbinginterrogators
133git-merge-file plumbingmanipulators
134git-merge-index plumbingmanipulators
135git-merge mainporcelain
136git-merge-one-file purehelpers
137git-merge-tree ancillaryinterrogators
138git-mergetool ancillarymanipulators
139git-mktag plumbingmanipulators
140git-mktree plumbingmanipulators
141git-mv mainporcelain
142git-name-rev plumbinginterrogators
143git-pack-objects plumbingmanipulators
144git-pack-redundant plumbinginterrogators
145git-pack-refs ancillarymanipulators
146git-parse-remote synchelpers
147git-patch-id purehelpers
148git-peek-remote purehelpers
149git-prune ancillarymanipulators
150git-prune-packed plumbingmanipulators
151git-pull mainporcelain
152git-push mainporcelain
153git-quiltimport foreignscminterface
154git-read-tree plumbingmanipulators
155git-rebase mainporcelain
156git-receive-pack synchelpers
157git-reflog ancillarymanipulators
158git-relink ancillarymanipulators
159git-repack ancillarymanipulators
160git-config ancillarymanipulators
161git-remote ancillarymanipulators
162git-request-pull foreignscminterface
163git-rerere ancillaryinterrogators
164git-reset mainporcelain
165git-revert mainporcelain
166git-rev-list plumbinginterrogators
167git-rev-parse ancillaryinterrogators
168git-rm mainporcelain
169git-runstatus ancillaryinterrogators
170git-send-email foreignscminterface
171git-send-pack synchingrepositories
172git-shell synchelpers
173git-shortlog mainporcelain
174git-show mainporcelain
175git-show-branch ancillaryinterrogators
176git-show-index plumbinginterrogators
177git-show-ref plumbinginterrogators
178git-sh-setup purehelpers
179git-ssh-fetch synchingrepositories
180git-ssh-upload synchingrepositories
181git-status mainporcelain
182git-stripspace purehelpers
183git-submodule mainporcelain
184git-svn foreignscminterface
185git-svnimport foreignscminterface
186git-symbolic-ref plumbingmanipulators
187git-tag mainporcelain
188git-tar-tree plumbinginterrogators
189git-unpack-file plumbinginterrogators
190git-unpack-objects plumbingmanipulators
191git-update-index plumbingmanipulators
192git-update-ref plumbingmanipulators
193git-update-server-info synchingrepositories
194git-upload-archive synchelpers
195git-upload-pack synchelpers
196git-var plumbinginterrogators
197git-verify-pack plumbinginterrogators
198git-verify-tag ancillaryinterrogators
199git-whatchanged ancillaryinterrogators
200git-write-tree plumbingmanipulators