4 use lib
"$FindBin::Bin/..";
5 use General
::FileSystem
;
8 chdir($FindBin::Bin
) || die "Can't chmod $FindBin::Bin: $!\n";
10 my $functable_src = "../../fvwm/functable.c";
11 my $content_ref = load_file
($functable_src);
12 die "No commands found, so Commands.pm is not generated.\n" unless $content_ref;
14 my $command_entries_code = "";
15 foreach my $entry ($$content_ref =~
16 m{(?:/\* )?CMD_ENT\(\s*(?:"|PRE_).*?\),(?: \*/)?.*?/\* .*?- .*? \*/}sg)
18 my ($name, $flags, $cursor, $name2, $descr) = $entry =~ m
{
25 .*?
/\*\s (?:(.+)\s)? -\s (.*?) \s\*/
27 $name = $name2 if $name2;
28 my $window = $flags =~ FUNC_NEEDS_WINDOW?
1: 0;
29 $cursor = "" if $cursor eq "0";
30 $command_entries_code .=
31 "\t{\n\t\tname => '$name',\n\t\tcursor => '$cursor',\n" .
32 "\t\twindow => $window,\n\t\tdescr => q{$descr},\n\t},\n";
35 my $version = `egrep '^VERSION = |^VERSIONINFO = ' Makefile | cut -d"=" -f2 \\
36 | perl -pe 's/^ //;s/\\n//'`;
39 my $output = <<ENDOUTPUT;
40 # Autogenerated from the fvwm sources.
42 package FVWM::Commands;
44 use vars qw(\$VERS \$TIME \@LIST);
50 $command_entries_code);
58 FVWM::Commands - lists all available fvwm commands
62 This class is autogenerated from the fvwm sources.
64 It may be used to get a list of all available fvwm commands including the
65 command name, its short description and some other command properties.
69 use lib `fvwm-perllib dir`;
73 my \$date = strftime("%d-%b-%Y", gmtime(\$FVWM::Commands::TIME));
74 my \$version = \$FVWM::Commands::VERS;
75 print "The recognized commands for fvwm \$version as of \$date:\\n\\n";
76 foreach my \$command (\@FVWM::Commands::LIST) {
77 printf " %-21s - %s\\n", \$command->{name}, \$command->{descr};
80 =head1 PUBLIC CONSTANTS
86 The fvwm version number at the generation time like "2.6.0" plus the info
87 that may indicate that this is not a final version, but a cvs snapshot.
91 The unix time of the command list generation.
95 print "The fvwm command list found on your system was generated "
96 . (time() - \$FVWM::Commands::TIME) / 86400 . " days ago\\n";
100 The command list that is an array of hashes with keys I<name>, I<cursor>,
101 I<descr> (string) and I<window> (boolean).
103 I<name> may be special, like "+", "#" and "*". Other names usually contain
104 only isalpha characters, like B<Move>, B<SendToModule>.
106 I<cursor> may be either empty or the cursor context used in B<CursorStyle>
107 (like "SELECT" or "MOVE"), associated with the command.
109 I<descr> is a short one line description of the command.
111 I<window> is true for commands that need a window.
115 # get command names only
116 \@command_names = map { \$_->{name} } \@FVWM::Commands::LIST;
122 Mikhael Goikhman <migo\@homemail.com>.
126 For more information about the commands themselves, see fvwm(1).
131 # ---------------------------------
132 print "Creating Commands.pm\n";
133 save_file
("Commands.pm", \
$output);
135 # ---------------------------------
136 print "Testing Commands.pm\n";
138 use lib
'$FindBin::Bin/..';
142 $FVWM::Commands
::TIME
||= 0; # avoid "used once" warning
144 my $date = strftime
("%d-%b-%Y", gmtime($FVWM::Commands
::TIME
));
145 my $cmds = "The recognized commands for fvwm $version as of $date:\n\n";
146 foreach my $command (@FVWM::Commands
::LIST
= @FVWM::Commands
::LIST
) {
147 $cmds .= sprintf " %-21s - %s\n", $command->{name
}, $command->{descr
};
150 # ---------------------------------
151 print "Creating ../../docs/COMMANDS\n";
152 save_file
("../../docs/COMMANDS", \
$cmds);