]> git.ipfire.org Git - thirdparty/git.git/blame - Documentation/cmd-list.perl
path.c: clarify trie_find()'s in-code comment
[thirdparty/git.git] / Documentation / cmd-list.perl
CommitLineData
d7907392
JH
1#!/usr/bin/perl -w
2
3use File::Compare qw(compare);
72fe6a59
JH
4
5sub format_one {
0bf15e74
JH
6 my ($out, $nameattr) = @_;
7 my ($name, $attr) = @$nameattr;
72fe6a59 8 my ($state, $description);
d7907392 9 $state = 0;
72fe6a59
JH
10 open I, '<', "$name.txt" or die "No such file $name.txt";
11 while (<I>) {
12 if (/^NAME$/) {
13 $state = 1;
14 next;
15 }
16 if ($state == 1 && /^----$/) {
17 $state = 2;
18 next;
19 }
20 next if ($state != 2);
21 chomp;
22 $description = $_;
23 last;
24 }
25 close I;
26 if (!defined $description) {
27 die "No description found in $name.txt";
28 }
29 if (my ($verify_name, $text) = ($description =~ /^($name) - (.*)/)) {
5162e697 30 print $out "linkgit:$name\[1\]::\n\t";
79d30668
JH
31 if ($attr =~ / deprecated /) {
32 print $out "(deprecated) ";
0bf15e74
JH
33 }
34 print $out "$text.\n\n";
72fe6a59
JH
35 }
36 else {
37 die "Description does not match $name: $description";
38 }
39}
40
11c6659d
ES
41while (<>) {
42 last if /^### command list/;
43}
44
72fe6a59 45my %cmds = ();
79d30668 46for (sort <>) {
72fe6a59
JH
47 next if /^#/;
48
49 chomp;
0bf15e74 50 my ($name, $cat, $attr) = /^(\S+)\s+(.*?)(?:\s+(.*))?$/;
79d30668
JH
51 $attr = '' unless defined $attr;
52 push @{$cmds{$cat}}, [$name, " $attr "];
72fe6a59
JH
53}
54
55for my $cat (qw(ancillaryinterrogators
56 ancillarymanipulators
57 mainporcelain
58 plumbinginterrogators
59 plumbingmanipulators
89bf2077
JH
60 synchingrepositories
61 foreignscminterface
62 purehelpers
63 synchelpers)) {
72fe6a59
JH
64 my $out = "cmds-$cat.txt";
65 open O, '>', "$out+" or die "Cannot open output file $out+";
66 for (@{$cmds{$cat}}) {
67 format_one(\*O, $_);
68 }
69 close O;
d7907392
JH
70
71 if (-f "$out" && compare("$out", "$out+") == 0) {
72 unlink "$out+";
73 }
74 else {
75 print STDERR "$out\n";
76 rename "$out+", "$out";
77 }
72fe6a59 78}