mktar: Use `wc` instead of `du` in summary message
[sunny256-utils.git] / scrplay
blob77e4476396cf863f3f1bb16c8e28beb9166655b4
1 #!/usr/bin/env perl
3 #=======================================================================
4 # scrplay
5 # File ID: cda34a16-f743-11dd-bcdb-000475e441b9
6 # Replays files with timing information created by script(1)
8 # Character set: UTF-8
9 # ©opyleft 2008– Øyvind A. Holm <sunny@sunbase.org>
10 # License: GNU General Public License version 2 or later, see end of
11 # file for legal stuff.
12 #=======================================================================
14 use strict;
15 use warnings;
16 use Getopt::Long;
18 $| = 1;
20 our $Debug = 0;
22 our %Opt = (
24 'debug' => 0,
25 'help' => 0,
26 'speed' => 1,
27 'verbose' => 0,
28 'version' => 0,
32 our $progname = $0;
33 $progname =~ s/^.*\/(.*?)$/$1/;
34 our $VERSION = "0.00";
36 Getopt::Long::Configure("bundling");
37 GetOptions(
39 "debug" => \$Opt{'debug'},
40 "help|h" => \$Opt{'help'},
41 "speed|s=f" => \$Opt{'speed'},
42 "verbose|v+" => \$Opt{'verbose'},
43 "version" => \$Opt{'version'},
45 ) || die("$progname: Option error. Use -h for help.\n");
47 $Opt{'debug'} && ($Debug = 1);
48 $Opt{'help'} && usage(0);
49 if ($Opt{'version'}) {
50 print_version();
51 exit(0);
54 if ($#ARGV >= 0) {
55 for (@ARGV) {
56 my $fname = $_;
57 $fname =~ s/(^.*)\.(scrlog|timing)/$1/;
58 system("reset");
59 system("scriptreplay", "-m", "0.5", "$fname.timing", "$fname.scrlog", $Opt{'speed'});
63 sub print_version {
64 # Print program version {{{
65 print("$progname v$VERSION\n");
66 # }}}
67 } # print_version()
69 sub usage {
70 # Send the help message to stdout {{{
71 my $Retval = shift;
73 if ($Opt{'verbose'}) {
74 print("\n");
75 print_version();
77 print(<<END);
79 Usage: $progname [options] [file [files [...]]]
81 Replay log files with timing information created by script(1). Expecting
82 .scrlog and .timing extensions.
84 Options:
86 -h, --help
87 Show this help.
88 -s x, --speed x
89 Replay files at speed x. 1 = normal, 2 = double, 0.5 = half, etc.
90 -v, --verbose
91 Increase level of verbosity. Can be repeated.
92 --version
93 Print version information.
94 --debug
95 Print debugging messages.
97 END
98 exit($Retval);
99 # }}}
100 } # usage()
102 sub msg {
103 # Print a status message to stderr based on verbosity level {{{
104 my ($verbose_level, $Txt) = @_;
106 if ($Opt{'verbose'} >= $verbose_level) {
107 print(STDERR "$progname: $Txt\n");
109 # }}}
110 } # msg()
112 sub D {
113 # Print a debugging message {{{
114 $Debug || return;
115 my @call_info = caller;
116 chomp(my $Txt = shift);
117 my $File = $call_info[1];
118 $File =~ s#\\#/#g;
119 $File =~ s#^.*/(.*?)$#$1#;
120 print(STDERR "$File:$call_info[2] $$ $Txt\n");
121 return("");
122 # }}}
123 } # D()
125 __END__
127 # Plain Old Documentation (POD) {{{
129 =pod
131 =head1 NAME
135 =head1 SYNOPSIS
137 [options] [file [files [...]]]
139 =head1 DESCRIPTION
143 =head1 OPTIONS
145 =over 4
147 =item B<-h>, B<--help>
149 Print a brief help summary.
151 =item B<-v>, B<--verbose>
153 Increase level of verbosity. Can be repeated.
155 =item B<--version>
157 Print version information.
159 =item B<--debug>
161 Print debugging messages.
163 =back
165 =head1 BUGS
169 =head1 AUTHOR
171 Made by Øyvind A. Holm S<E<lt>sunny@sunbase.orgE<gt>>.
173 =head1 COPYRIGHT
175 Copyleft © Øyvind A. Holm E<lt>sunny@sunbase.orgE<gt>
176 This is free software; see the file F<COPYING> for legalese stuff.
178 =head1 LICENCE
180 This program is free software: you can redistribute it and/or modify it
181 under the terms of the GNU General Public License as published by the
182 Free Software Foundation, either version 2 of the License, or (at your
183 option) any later version.
185 This program is distributed in the hope that it will be useful, but
186 WITHOUT ANY WARRANTY; without even the implied warranty of
187 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
188 See the GNU General Public License for more details.
190 You should have received a copy of the GNU General Public License along
191 with this program.
192 If not, see L<http://www.gnu.org/licenses/>.
194 =head1 SEE ALSO
196 =cut
198 # }}}
200 # vim: set fenc=UTF-8 ft=perl fdm=marker ts=4 sw=4 sts=4 et fo+=w :