Login | Register
My pages Projects Community openCollabNet

Discussions > cvs > CVS update: /svnutils/trunk/src/

svnutils
Discussion topic

Back to topic list

CVS update: /svnutils/trunk/src/

Author sunny256
Full name Øyvind A. Holm
Date 2005-08-20 07:36:53 PDT
Message User: sunny256
Date: 2005/08/20 07:36:53

Modified:
   svnutils/trunk/src/sident

Log:
 r149 | sunny256 | 2005-08-20 02:07:05 +0000 (Sat, 20 Aug 2005) | 10 lines
 
 sident(1): Add long options and a standard debugging function which
 probaly is nice to have in the future. Based on the standard Perl
 template file at http://svn.sunbase.o​rg/repos/utils/trunk​/Lib/std/perl
 r1340.
 
 * /trunk/src/sident
   - Added long versions of the options: --known-keywords-only and
     --filenames-only .
   (D): New subroutine. Debugging stuff which is nice to have around.

File Changes:

Directory: /svnutils/trunk/src/
===============================

File [changed]: sident
Url: http://svnutils.tigr​is.org/source/browse​/svnutils/trunk/src/​sident?r1=1.6&r2​=1.7
Delta lines: +52 -19
---------------------
--- sident 1 May 2005 01:36:02 -0000 1.6
+++ sident 20 Aug 2005 14:36:50 -0000 1.7
@@ -1,7 +1,7 @@
 #!/usr/bin/perl -w
 
 #===================​====================​====================​============
-# $Id: sident 133 2005-05-01 01:27:12Z sunny256 $
+# $Id: sident 149 2005-08-20 02:07:05Z sunny256 $
 # Lists RCS-like keywords in files. Replacement for ident(1).
 #
 # Character set: UTF-8
@@ -10,13 +10,32 @@
 #===================​====================​====================​============
 
 use strict;
+use Getopt::Long;
 
 $| = 1;
 
-use Getopt::Std;
-our ($opt_h, $opt_k, $opt_l) =
+our $Debug = 0;
+
+our ($opt_help, $opt_known, $opt_namesonly) =
     ( 0, 0, 0);
-getopts('hkl') || die("Option error. Use -h for help.\n");
+
+my $VERSION = "0.0";
+
+our $progname = $0;
+$progname =~ s#^.*/(.*?)$#$1#;
+
+my $rcs_id = '$Id: sident 149 2005-08-20 02:07:05Z sunny256 $';
+my $id_date = $rcs_id;
+$id_date =~ s/^.*?\d+ (\d\d\d\d-.*?\d​\d:\d\d:\d\d\S​+).*/$1/;
+
+Getopt::Long::Confi​gure("bundling");
+GetOptions(
+ "help|h" => \$opt_help,
+ "known-keywords-only|k" => \$opt_known,
+ "filenames-only|l" => \$opt_namesonly
+) || die("$progname: Option error. Use -h for help.\n");
+
+$opt_help && usage(0);
 
 my @Keywords = (
                 "Id",
@@ -32,9 +51,7 @@
                 "Source",
                 "State"
                );
-my $Keyw = $opt_k ? join('|', @Keywords) : '[A-Za-z]+'; # Used in regexps
-
-$opt_h && usage(0);
+my $Keyw = $opt_known ? join('|', @Keywords) : '[A-Za-z]+'; # Used in regexps
 
 for (@ARGV) {
     my @Out = ();
@@ -45,7 +62,7 @@
             s/(\$($Keyw)::? .*? \$)/push(@Out, " $1\n")/ge;
         }
         if (scalar(@Out)) {
- if ($opt_l) {
+ if ($opt_namesonly) {
                 print("$File\n");
             } else {
                 print("\n$File:\n");
@@ -62,17 +79,20 @@
     my $Retval = shift;
     print(<<END);
 
-Usage:
+$progname v$VERSION -- $id_date
 
- sident [options] file [files [...]]
+Usage: $progname [options] [file [files [...]]]
 
 Lists RCS-like keywords in a file.
 
 Options:
 
- -h Print this help
- -k Only list keywords known to Subversion and CVS
- -l Suppress normal output; only list names of files which contain
+ -h, --help
+ Show this help.
+ -k, --known-keywords-only
+ Only list keywords known to Subversion and CVS
+ -l, --filenames-only
+ Suppress normal output; only list names of files which contain
       keywords
 
 END
@@ -80,6 +100,19 @@
     # }}}
 }
 
+sub D {
+ # {{{
+ $Debug || return;
+ my @call_info = caller;
+ chomp(my $Txt = shift);
+ my $File = $call_info[1];
+ $File =~ s#\\#/#g;
+ $File =~ s#^.*/(.*?)$#$1#;
+ print(STDERR "$File:$call_info[2] $$ $Txt\n");
+ return("");
+ # }}}
+} # D()
+
 __END__
 
 # Plain Old Documentation (POD) {{{
@@ -92,7 +125,7 @@
 
 =head1 REVISION
 
-$Id: sident 133 2005-05-01 01:27:12Z sunny256 $
+$Id: sident 149 2005-08-20 02:07:05Z sunny256 $
 
 =head1 SYNOPSIS
 
@@ -106,15 +139,15 @@
 
 =over 4
 
-=item B<-h>
+=item B<-h>, B<--help>
 
 Print a brief help summary.
 
-=item B<-k>
+=item B<-k>, B<--known-keywords-only>
 
 Only list keywords known to Subversion and CVS.
 
-=item B<-l>
+=item B<-l>, B<--filenames-only>
 
 Suppress normal output; only list names of files which contains
 keywords.
@@ -157,4 +190,4 @@
 # }}}
 
 # vim: set fenc=UTF-8 ft=perl fdm=marker ts=4 sw=4 sts=4 et fo+=w :
-# End of file $Id: sident 133 2005-05-01 01:27:12Z sunny256 $
+# End of file $Id: sident 149 2005-08-20 02:07:05Z sunny256 $

« Previous message in topic | 1 of 1 | Next message in topic »

Messages

Show all messages in topic

CVS update: /svnutils/trunk/src/ sunny256 Øyvind A. Holm 2005-08-20 07:36:53 PDT
Messages per page: