-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathactions_list.pl
executable file
·114 lines (78 loc) · 1.95 KB
/
actions_list.pl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
#!/usr/bin/env perl
=pod
=head1 NAME
actions_list.pl - Create a list of Padre Actions
=head1 SYNOPSIS
actions_list.pl --text actions.dump
actions_list.pl --html actions.dump
=head1 DESCRIPTION
This script creates a list of all actions supported by Padre
and outputs it in text or HTML-format. The default is text format.
=head1 USAGE
Set the environment variable PADRE_EXPORT_ACTIONS to 1 and then
run Padre.
PADRE_EXPORT_ACTIONS=1 ./dev
It will create a actions.dump - file in your config dir
(usually ~/.padre on Linux). Just pass this file to actions_list.pl
=cut
use 5.006;
use strict;
use warnings;
our $VERSION = '0.03';
package Local::Output::Text;
sub start {
my $self = shift;
}
sub action {
my $self = shift;
my $action = shift;
print "***** " . $action->{name} . " *****\n";
print 'Default shortcut: ' . $action->{shortcut} . "\n" if defined( $action->{shortcut} );
print $action->{comment} . "\n" if defined( $action->{comment} );
print "\n";
}
sub finish {
my $self = shift;
}
package Local::Output::HTML;
sub start {
my $self = shift;
print <<_EOT_;
<html><body><table border=1>
<th><td>Action</td><td>Default<br>shortcut</td><td>Comment</td></th>
_EOT_
}
sub action {
my $self = shift;
my $action = shift;
print '<tr>' . '<td>'
. $action->{name} . '</td>' . '<td>'
. ( defined( $action->{shortcut} ) ? $action->{shortcut} : '' ) . '</td>' . '<td>'
. ( defined( $action->{comment} ) ? $action->{comment} : '' ) . '</td>'
. "</tr>\n";
}
sub finish {
my $self = shift;
print '</table></body></html>';
}
my %actions;
our $VAR1;
my $Formatter = 'Local::Output::Text';
for (@ARGV) {
if ( $_ eq '--text' ) {
$Formatter = 'Local::Output::Text';
next;
} elsif ( $_ eq '--html' ) {
$Formatter = 'Local::Output::HTML';
next;
}
require $_;
for ( keys( %{$VAR1} ) ) {
$actions{$_} = $VAR1->{$_};
}
}
$Formatter->start;
for ( sort( keys(%actions) ) ) {
$Formatter->action( $actions{$_} );
}
$Formatter->finish;