mktar: Use `wc` instead of `du` in summary message
[sunny256-utils.git] / Lib / std / perl
blob77b52c9cd5da96cc4747aa1a8632415899cc5aa5
1 #!/usr/bin/env perl
3 #==============================================================================
4 # STDfilenameDTS
5 # File ID: STDuuidDTS
7 # [Description]
9 # Character set: UTF-8
10 # ©opyleft STDyearDTS– Øyvind A. Holm <sunny@sunbase.org>
11 # License: GNU General Public License version 2 or later, see end of file for
12 # legal stuff.
13 #==============================================================================
15 use strict;
16 use warnings;
17 use Getopt::Long;
19 local $| = 1;
21 our %Opt = (
23 'help' => 0,
24 'quiet' => 0,
25 'verbose' => 0,
26 'version' => 0,
30 our $progname = $0;
31 $progname =~ s/^.*\/(.*?)$/$1/;
32 our $VERSION = '0.0.0';
34 Getopt::Long::Configure('bundling');
35 GetOptions(
37 'help|h' => \$Opt{'help'},
38 'quiet|q+' => \$Opt{'quiet'},
39 'verbose|v+' => \$Opt{'verbose'},
40 'version' => \$Opt{'version'},
42 ) || die("$progname: Option error. Use -h for help.\n");
44 $Opt{'verbose'} -= $Opt{'quiet'};
45 $Opt{'help'} && usage(0);
46 if ($Opt{'version'}) {
47 print_version();
48 exit(0);
51 exit(main());
53 sub main {
54 my $Retval = 0;
56 return $Retval;
59 sub print_version {
60 # Print program version
61 print("$progname $VERSION\n");
62 return;
65 sub usage {
66 # Send the help message to stdout
67 my $Retval = shift;
69 if ($Opt{'verbose'}) {
70 print("\n");
71 print_version();
73 print(<<"END");
75 Usage: $progname [options] [file [files [...]]]
77 Options:
79 -h, --help
80 Show this help.
81 -q, --quiet
82 Be more quiet. Can be repeated to increase silence.
83 -v, --verbose
84 Increase level of verbosity. Can be repeated.
85 --version
86 Print version information.
88 END
89 exit($Retval);
92 sub msg {
93 # Print a status message to stderr based on verbosity level
94 my ($verbose_level, $Txt) = @_;
96 $verbose_level > $Opt{'verbose'} && return;
97 print(STDERR "$progname: $Txt\n");
98 return;
101 __END__
103 # This program is free software; you can redistribute it and/or modify it under
104 # the terms of the GNU General Public License as published by the Free Software
105 # Foundation; either version 2 of the License, or (at your option) any later
106 # version.
108 # This program is distributed in the hope that it will be useful, but WITHOUT
109 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
110 # FOR A PARTICULAR PURPOSE.
111 # See the GNU General Public License for more details.
113 # You should have received a copy of the GNU General Public License along with
114 # this program.
115 # If not, see L<http://www.gnu.org/licenses/>.
117 # vim: set fenc=UTF-8 ft=perl fdm=marker ts=4 sw=4 sts=4 et fo+=w :