[Rt-commit] rt branch, 3.9-trunk, updated. rt-3.8.8-508-g11f1b99

? sunnavy sunnavy at bestpractical.com
Mon Aug 23 19:22:17 EDT 2010


The branch, 3.9-trunk has been updated
       via  11f1b9936611966d0cdb07ac8d07aa268e343fb6 (commit)
      from  57cc84f2056eb712cead16d37db211ad44897769 (commit)

Summary of changes:
 bin/rt-mailgate.in           |    9 +-
 bin/standalone_httpd.in      |   31 +++++++-
 sbin/rt-attributes-viewer.in |   38 ++++++---
 sbin/rt-clean-sessions.in    |   19 ++---
 sbin/rt-dump-database.in     |   38 +++++++++-
 sbin/rt-email-dashboards.in  |   50 +++++++------
 sbin/rt-email-group-admin.in |   37 +++++-----
 sbin/rt-server.in            |   34 ++++++++-
 sbin/rt-setup-database.in    |  167 ++++++++++++++++++++++++++----------------
 sbin/rt-test-dependencies.in |  137 +++++++++++++++++++++++-----------
 sbin/rt-validator.in         |   76 +++++++++++++------
 11 files changed, 428 insertions(+), 208 deletions(-)

- Log -----------------------------------------------------------------
commit 11f1b9936611966d0cdb07ac8d07aa268e343fb6
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Tue Aug 24 07:22:27 2010 +0800

    use consistent help system for most of scripts

diff --git a/bin/rt-mailgate.in b/bin/rt-mailgate.in
index 9dc800f..ac2400e 100755
--- a/bin/rt-mailgate.in
+++ b/bin/rt-mailgate.in
@@ -68,8 +68,7 @@ GetOptions( \%opts, "queue=s", "action=s", "url=s", "jar=s", "help", "debug", "e
 
 if ( $opts{'help'} ) {
     require Pod::Usage;
-    import Pod::Usage;
-    pod2usage("RT Mail Gateway\n");
+    Pod::Usage::pod2usage({verbose =>2});
     exit 1;    # Don't want to succeed if this is really an email!
 }
 
@@ -290,6 +289,8 @@ Print debugging output to standard error
 Configure the timeout for posting the message to the web server.  The
 default timeout is 3 minutes (180 seconds).
 
+=back
+
 
 =head1 DESCRIPTION
 
@@ -379,7 +380,7 @@ If we don't already have a ticket id, we need to know which queue we're talking
 
 The action being performed. At the moment, it's one of "comment" or "correspond"
 
-=back 4
+=back
 
 It returns two values, the new C<RT::CurrentUser> object, and the new
 authentication level. The authentication level can be zero, not allowed
@@ -403,7 +404,7 @@ See also C<--extension> option. Note that value of the environment variable is
 always added to the message header when it's not empty even if C<--extension>
 option is not provided.
 
-=back 4
+=back
 
 =cut
 
diff --git a/bin/standalone_httpd.in b/bin/standalone_httpd.in
index 997960c..6f8a1d4 100755
--- a/bin/standalone_httpd.in
+++ b/bin/standalone_httpd.in
@@ -74,8 +74,19 @@ BEGIN {
 
 }
 
-use RT;
-RT::LoadConfig();
+use Getopt::Long;
+my %opt;
+GetOptions(\%opt, 'help|h');
+
+no warnings 'once';
+if ( $opt{help} ) {
+    require Pod::Usage;
+    print Pod::Usage::pod2usage( { verbose => 2 } );
+    exit;
+}
+
+require RT;
+RT->LoadConfig();
 RT->InitLogging();
 if (RT->Config->Get('DevelMode')) { require Module::Refresh; }
 
@@ -184,3 +195,19 @@ EOF
         run_server( 8000 + int( rand(1024) ) );
     }
 }
+
+__END__
+
+=head1 NAME
+
+standalone_httpd - RT standalone server
+
+=head1 SYNOPSIS
+
+    # runs server listening on port 8080
+    standalone_httpd 8080
+
+=head1 DESCRIPTION
+
+This script runs an RT server using C<RT::Interface::Web::Standalone>
+
diff --git a/sbin/rt-attributes-viewer.in b/sbin/rt-attributes-viewer.in
index f81c499..1ef3aaf 100644
--- a/sbin/rt-attributes-viewer.in
+++ b/sbin/rt-attributes-viewer.in
@@ -73,21 +73,16 @@ BEGIN {
     }
 }
 
-my $id = shift;
-usage() unless $id;
-
-sub usage {
-    print STDERR <<END;
-Usage: $0 <attribute id>
-
-Description:
+use Getopt::Long;
+my %opt;
+GetOptions( \%opt, 'help|h', );
 
-This script deserializes and print content of an attribute defined
-by <attribute id>. May be useful for developers and for troubleshooting
-problems.
+my $id = shift;
 
-END
-    exit 1;
+if ( $opt{help} || !$id ) {
+    require Pod::Usage;
+    Pod::Usage::pod2usage({ verbose => 2 });
+    exit;
 }
 
 require RT;
@@ -108,3 +103,20 @@ $res{$_} = $attr->$_() foreach qw(ObjectType ObjectId Name Description Content C
 use Data::Dumper;
 print "Content of attribute #$id: ". Dumper( \%res );
 
+__END__
+
+=head1 NAME
+
+rt-attributes-viewer - show the content of an attribute 
+
+=head1 SYNOPSIS
+
+    # show the content of attribute 2
+    rt-attributes-viewer 2  
+
+=head1 DESCRIPTION
+
+This script deserializes and print content of an attribute defined
+by <attribute id>. May be useful for developers and for troubleshooting
+problems.
+
diff --git a/sbin/rt-clean-sessions.in b/sbin/rt-clean-sessions.in
index ac2c04d..1228923 100644
--- a/sbin/rt-clean-sessions.in
+++ b/sbin/rt-clean-sessions.in
@@ -75,14 +75,13 @@ BEGIN {
 
 use Getopt::Long;
 my %opt;
-GetOptions( \%opt, "older=s", "debug", "help", "skip-user");
+GetOptions( \%opt, "older=s", "debug", "help|h", "skip-user" );
 
 
 if ( $opt{help} ) {
     require Pod::Usage;
-    import Pod::Usage;
-    pod2usage({ -message => "RT Session cleanup tool\n", verbose => 1 });
-    exit 1;    
+    Pod::Usage::pod2usage({ verbose => 2 });
+    exit;    
 }
 
 
@@ -137,13 +136,13 @@ rt-clean-sessions - clean old and duplicate RT sessions
 
 =head1 SYNOPSIS
 
-    rt-clean-sessions [--debug] [--older <NUM>[H|D|M|Y]]
+     rt-clean-sessions [--debug] [--older <NUM>[H|D|M|Y]]
 
-    rt-clean-sessions
-    rt-clean-sessions --debug
-    rt-clean-sessions --older 10D
-    rt-clean-sessions --debug --older 1M
-    rt-clean-sessions --older 10D --skip-user
+     rt-clean-sessions
+     rt-clean-sessions --debug
+     rt-clean-sessions --older 10D
+     rt-clean-sessions --debug --older 1M
+     rt-clean-sessions --older 10D --skip-user
 
 =head1 DESCRIPTION
 
diff --git a/sbin/rt-dump-database.in b/sbin/rt-dump-database.in
index 4e74678..ae72b65 100755
--- a/sbin/rt-dump-database.in
+++ b/sbin/rt-dump-database.in
@@ -77,8 +77,18 @@ BEGIN {
 
 }
 
-use RT;
-use XML::Simple;
+use Getopt::Long;
+my %opt;
+GetOptions( \%opt, "help|h" );
+
+if ( $opt{help} ) {
+    require Pod::Usage;
+    Pod::Usage::pod2usage( { verbose => 2 } );
+    exit;
+}
+
+require RT;
+require XML::Simple;
 
 RT::LoadConfig();
 RT::Init();
@@ -190,10 +200,32 @@ no strict; use XML::Simple; *_ = XMLin(do { local \$/; readline(DATA) }, ForceAr
 __DATA__
 .
 
-print XMLout(
+print XML::Simple::XMLout(
     { map { ($_ => ($RV{$_} || [])) } @classes },
     RootName => 'InitialData',
     NoAttr => 1,
     SuppressEmpty => '',
     XMLDecl => '<?xml version="1.0" encoding="UTF-8"?>',
 );
+
+__END__
+
+=head1 NAME
+
+rt-dump-database - dump the Request Tracker database
+
+=head1 SYNOPSIS
+
+    rt-dump-database [ 0 ]
+
+=head1 DESCRIPTION
+
+C<rt-dump-database> is a tool that dumps the Request Tracker database
+into XML format, suitable for feeding into C<rt-setup-database>.
+
+When run without arguments, the database dump will only include 'local'
+configuration changes, i.e. those done manually in the web interface.
+
+When run with the argument '0', the dump will include all configuration
+metadata.
+
diff --git a/sbin/rt-email-dashboards.in b/sbin/rt-email-dashboards.in
index 42100da..47fb071 100644
--- a/sbin/rt-email-dashboards.in
+++ b/sbin/rt-email-dashboards.in
@@ -74,16 +74,31 @@ BEGIN {
 
 }
 
-use RT;
-use RT::Interface::CLI qw{ CleanEnv loc };
-
+# Read in the options
+my %opts;
 use Getopt::Long;
-use HTML::Mason;
-use HTML::RewriteAttributes::Resources;
-use HTML::RewriteAttributes::Links;
-use MIME::Types;
-use POSIX 'tzset';
-use File::Temp 'tempdir';
+GetOptions( \%opts,
+    "help|h", "dryrun", "verbose", "debug", "epoch=i", "all", "skip-acl"
+);
+
+if ($opts{'help'}) {
+    require Pod::Usage;
+    print Pod::Usage::pod2usage(-verbose => 2);
+    exit;
+}
+
+require RT;
+require RT::Interface::CLI;
+RT::Interface::CLI->import(qw{ CleanEnv loc });
+
+require HTML::Mason;
+require HTML::RewriteAttributes::Resources;
+require HTML::RewriteAttributes::Links;
+require MIME::Types;
+require POSIX;
+POSIX->import('tzset');
+require File::Temp;
+File::Temp->import('tempdir');
 
 # Clean out all the nasties from the environment
 CleanEnv();
@@ -101,19 +116,6 @@ $HTML::Mason::Commands::r = RT::Dashboard::FakeRequest->new;
 
 no warnings 'once';
 
-# Read in the options
-my %opts;
-GetOptions( \%opts,
-    "help", "dryrun", "verbose", "debug", "epoch=i", "all", "skip-acl"
-);
-
-if ($opts{'help'}) {
-    require Pod::Usage;
-    import Pod::Usage;
-    pod2usage(-message => "RT Email Dashboards\n", -verbose => 1);
-    exit 1;
-}
-
 # helper functions
 sub verbose  { print loc(@_), "\n" if $opts{debug} || $opts{verbose}; 1 }
 sub debug    { print loc(@_), "\n" if $opts{debug}; 1 }
@@ -506,7 +508,7 @@ rt-email-dashboards - Send email dashboards
 
 =head1 SYNOPSIS
 
-    /opt/rt3/local/sbin/rt-email-dashboards [options]
+    rt-email-dashboards [options]
 
 =head1 DESCRIPTION
 
@@ -533,6 +535,8 @@ This tool supports a few options. Most are for debugging.
 
 =over 8
 
+=item -h
+
 =item --help
 
 Display this documentation
diff --git a/sbin/rt-email-group-admin.in b/sbin/rt-email-group-admin.in
index 20e80d1..1db29cc 100755
--- a/sbin/rt-email-group-admin.in
+++ b/sbin/rt-email-group-admin.in
@@ -111,23 +111,14 @@ BEGIN {
 
 }
 
-use RT;
-RT::LoadConfig;
-RT::Init;
-
-require RT::Principal;
-require RT::User;
-require RT::Group;
-require RT::ScripActions;
-
 use Getopt::Long qw(GetOptions);
+Getopt::Long::Configure( "pass_through" );
 
 our $cmd = 'usage';
 our $opts = {};
 
 sub parse_args {
     my $tmp;
-    Getopt::Long::Configure( "pass_through" );
     if ( GetOptions( 'list' => \$tmp ) && $tmp ) {
         $cmd = 'list';
     }
@@ -180,18 +171,28 @@ sub parse_args {
 }
 
 sub usage {
-    local $@;
-    eval "require Pod::PlainText;";
-    if ( $@ ) {
-        print "see `perldoc $0`\n";
-    } else {
-        my $parser = Pod::PlainText->new( sentence => 0, width => 78 );
-        $parser->parse_from_file( $0 );
-    }
+    require Pod::Usage;
+    Pod::Usage::pod2usage({ verbose => 2 });
+}
+
+my $help;
+if ( GetOptions( 'help|h' => \$help ) && $help ) {
+    usage();
+    exit;
 }
 
 parse_args();
 
+require RT;
+RT->LoadConfig;
+RT->Init;
+
+require RT::Principal;
+require RT::User;
+require RT::Group;
+require RT::ScripActions;
+
+
 {
     eval "main::$cmd()";
     if ( $@ ) {
diff --git a/sbin/rt-server.in b/sbin/rt-server.in
index e635d03..8b04eb9 100644
--- a/sbin/rt-server.in
+++ b/sbin/rt-server.in
@@ -74,15 +74,28 @@ BEGIN {
 
 }
 
-use RT;
-RT::LoadConfig();
+use Getopt::Long;
+
+my %opt;
+GetOptions(\%opt, 'help|h');
+
+if ( $opt{help} ) {
+    require Pod::Usage;
+    Pod::Usage::pod2usage( { verbose => 2 } );
+    exit;
+}
+
+my $port = shift @ARGV || RT->Config->Get('WebPort') || '8080';
+
+
+require RT;
+RT->LoadConfig();
 RT->InitLogging();
 if (RT->Config->Get('DevelMode')) { require Module::Refresh; }
 
 RT::CheckPerlRequirements();
 RT->InitPluginPaths();
 
-my $port = shift @ARGV || RT->Config->Get('WebPort') || '8080';
 
 
 require RT::Handle;
@@ -127,3 +140,18 @@ $server->net_server('RT::Interface::Web::Standalone::PreFork');
 $server->port($port);
 $server->run();
 
+__END__
+
+=head1 NAME
+
+rt-server - RT standalone server with prefork
+
+=head1 SYNOPSIS
+
+    # runs server listening on port 8080
+    rt-server 8080
+
+=head1 DESCRIPTION
+
+This script runs an RT server using C<RT::Interface::Web::Standalone::PreFork>
+
diff --git a/sbin/rt-setup-database.in b/sbin/rt-setup-database.in
index 1740fd0..46937aa 100755
--- a/sbin/rt-setup-database.in
+++ b/sbin/rt-setup-database.in
@@ -76,15 +76,6 @@ BEGIN {
 
 }
 
-#This drags in  RT's config.pm
-# We do it in a begin block because RT::Handle needs to know the type to do its
-# inheritance
-BEGIN {
-    use RT;
-    RT::LoadConfig();
-    RT::InitClasses();
-}
-
 use Term::ReadKey;
 use Getopt::Long;
 
@@ -96,14 +87,21 @@ GetOptions(
     'action=s',
     'force', 'debug',
     'dba=s', 'dba-password=s', 'prompt-for-dba-password',
-    'datafile=s', 'datadir=s', 'skip-create', 'root-password-file=s'
+    'datafile=s', 'datadir=s', 'skip-create', 'root-password-file=s',
+    'help|h',
 );
 
-unless ( $args{'action'} ) {
-    help();
-    exit(-1);
+no warnings 'once';
+if ( $args{help} || ! $args{'action'} ) {
+    require Pod::Usage;
+    Pod::Usage::pod2usage({ verbose => 2 });
+    exit;
 }
 
+require RT;
+RT->LoadConfig();
+RT->InitClasses();
+
 # get customized root password
 my $root_password;
 if ( $args{'root-password-file'} ) {
@@ -397,13 +395,10 @@ sub get_dba_password {
     return ($password);
 }
 
-=head2 get_system_dbh
+#   get_system_dbh
+#   Returns L<DBI> database handle connected to B<system> with DBA credentials.
+#   See also L<RT::Handle/SystemDSN>.
 
-Returns L<DBI> database handle connected to B<system> with DBA credentials.
-
-See also L<RT::Handle/SystemDSN>.
-
-=cut
 
 sub get_system_dbh {
     return _get_dbh( RT::Handle->SystemDSN, $dba_user, $dba_pass );
@@ -413,13 +408,11 @@ sub get_admin_dbh {
     return _get_dbh( RT::Handle->DSN, $dba_user, $dba_pass );
 }
 
-=head2 get_rt_dbh [USER, PASSWORD]
-
-Returns L<DBI> database handle connected to RT database,
-you may specify credentials(USER and PASSWORD) to connect
-with. By default connects with credentials from RT config.
+# get_rt_dbh [USER, PASSWORD]
 
-=cut
+# Returns L<DBI> database handle connected to RT database,
+# you may specify credentials(USER and PASSWORD) to connect
+# with. By default connects with credentials from RT config.
 
 sub get_rt_dbh {
     return _get_dbh( RT::Handle->DSN, $db_user, $db_pass );
@@ -448,59 +441,105 @@ sub _yesno {
     $x =~ /^y/i;
 }
 
-sub help {
+1;
+
+__END__
 
-    print <<EOF;
+=head1 NAME
 
-$0: Set up RT's database
+rt-setup-database - Set up RT's database
 
---action        init     Initialize the database. This is combination of
-                         multiple actions listed below. Create DB, schema,
-                         setup acl, insert core data and initial data.
+=head1 SYNOPSIS
 
-                upgrade  Apply all needed schema/acl/content updates (will ask
-                         for version to upgrade from)
+    rt-setup-database --action ... 
 
-                create   Create the database.
+=head1 OPTIONS
 
-                drop     Drop the database.
-                         This will ERASE ALL YOUR DATA
+=over
 
-                schema   Initialize only the database schema
-                         To use a local or supplementary datafile, specify it
-                         using the '--datadir' option below.
+=item action
 
-                acl      Initialize only the database ACLs
-                         To use a local or supplementary datafile, specify it
-                         using the '--datadir' option below.
+Several actions can be combined using comma separated list.
 
-                coredata Insert data into RT's database. This data is required
-                         for normal functioning of any RT instance.
+=over
 
-                insert   Insert data into RT's database.
-                         By default, will use RT's installation data.
-                         To use a local or supplementary datafile, specify it
-                         using the '--datafile' option below.
+=item init
 
-Several actions can be combined using comma separated list.
+    Initialize the database. This is combination of multiple actions listed 
+    below. Create DB, schema, setup acl, insert core data and initial data.
 
---datafile /path/to/datafile
---datadir /path/to/              Used to specify a path to find the local
-                                 database schema and acls to be installed.
+=item upgrade
 
+    Apply all needed schema/acl/content updates (will ask for version to 
+    upgrade from)
 
---dba                           dba's username
---dba-password                  dba's password
---prompt-for-dba-password       Ask for the database administrator's password interactively
---skip-create                   for 'init': skip creating the database and the
-                                user account, so we don't need administrator
-                                privileges
---root-password-file            for 'init' and 'insert': rather than using the default 
-                                administrative password for RT's "root" user, use
-                                the password in this file.
+=item create
 
-EOF
+    Create the database.
 
-}
+=item drop
 
-1;
+    Drop the database.
+    This will ERASE ALL YOUR DATA
+
+=item schema
+
+    Initialize only the database schema
+    To use a local or supplementary datafile, specify it
+    using the '--datadir' option below.
+
+
+=item acl
+    Initialize only the database ACLs
+    To use a local or supplementary datafile, specify it
+    using the '--datadir' option below.
+
+=item coredata 
+
+    Insert data into RT's database. This data is required
+    for normal functioning of any RT instance.
+
+=item insert
+    Insert data into RT's database.
+    By default, will use RT's installation data.
+    To use a local or supplementary datafile, specify it
+    using the '--datafile' option below.
+
+=back
+
+
+=item datafile
+
+file path of the data you want to action on
+
+e.g. --datafile /path/to/datafile
+
+=item datadir
+
+    Used to specify a path to find the local database schema and acls to be
+    installed.
+
+e.g. --datadir /path/to/
+
+=item dba
+
+    dba's username
+=item dba-password
+
+    dba's password
+
+=item prompt-for-dba-password
+
+Ask for the database administrator's password interactively
+
+=item skip-create
+
+    for 'init': skip creating the database and the user account, so we don't
+    need administrator privileges
+
+=item root-password-file
+
+    for 'init' and 'insert': rather than using the default administrative 
+    password for RT's "root" user, use the password in this file.
+
+=back
diff --git a/sbin/rt-test-dependencies.in b/sbin/rt-test-dependencies.in
index 6de8b14..a080ec8 100755
--- a/sbin/rt-test-dependencies.in
+++ b/sbin/rt-test-dependencies.in
@@ -74,12 +74,14 @@ GetOptions(
 
     'download=s',
     'repository=s',
-    'list-deps'
+    'list-deps',
+    'help|h',
 );
 
-unless (keys %args) {
-    help();
-    exit(1);
+if ( $args{help} ) {
+    require Pod::Usage;
+    Pod::Usage::pod2usage( { verbose => 2 } );
+    exit;
 }
 
 # Set up defaults
@@ -156,44 +158,6 @@ sub conclude {
     }
 }
 
-
-sub help {
-
-    print <<'.';
-
-By default, testdeps determine whether you have 
-installed all the perl modules RT needs to run.
-
-    --install           Install missing modules
-
-The following switches will tell the tool to check for specific dependencies
-
-    --with-mysql        Database interface for MySQL
-    --with-postgresql   Database interface for PostgreSQL 
-    --with-oracle       Database interface for Oracle
-    --with-sqlite       Database interface and driver for SQLite (unsupported)
-
-    --with-standalone     Libraries needed to support the standalone simple pure perl server
-    --with-fastcgi-server Libraries needed to support the external fastcgi server
-    --with-fastcgi        Libraries needed to support the fastcgi handler
-    --with-speedycgi      Libraries needed to support the speedycgi handler
-    --with-modperl1       Libraries needed to support the modperl 1 handler
-    --with-modperl2       Libraries needed to support the modperl 2 handler
-
-    --with-dev          Tools needed for RT development
-
-You can also specify -v or --verbose to list the status of all dependencies,
-rather than just the missing ones.
-
-The "RT_FIX_DEPS_CMD" environment variable, if set, will be used
-instead of the standard CPAN shell by --install to install any
-required modules.  It will be called with the module name, or, if
-"RT_FIX_DEPS_CMD" contains a "%s", will replace the "%s" with the
-module name before calling the program.
-.
-}
-
-
 sub text_to_hash {
     my %hash;
     for my $line ( split /\n/, $_[0] ) {
@@ -598,6 +562,93 @@ sub check_users {
   print_found("web group (@WEB_GROUP@)",   defined getgrnam("@WEB_GROUP@"));
 }
 
+1;
+
+__END__
 
+=head1 NAME
+
+rt-test-dependencies - test rt's dependencies
+
+=head1 SYNOPSIS
+
+    rt-test-dependencies
+    rt-test-dependencies --install
+    rt-test-dependencies --with-mysql --with-fastcgi
+
+=head1 DESCRIPTION
+
+by default, C<rt-test-dependencies> determines whether you have installed all
+the perl modules RT needs to run.
+
+the "RT_FIX_DEPS_CMD" environment variable, if set, will be used instead of
+the standard CPAN shell by --install to install any required modules.  it will
+be called with the module name, or, if "RT_FIX_DEPS_CMD" contains a "%s", will
+replace the "%s" with the module name before calling the program.
+
+=head1 OPTIONS
+
+=over
+
+=item install
+
+    install missing modules
+
+=item verbose
+
+list the status of all dependencies, rather than just the missing ones.
+
+-v is equal to --verbose
+
+=item specify dependencies
+
+=over
+
+=item --with-mysql
+
+    database interface for mysql
+
+=item --with-postgresql
+
+    database interface for postgresql 
+
+=item with-oracle       
+    
+    database interface for oracle
+
+=item with-sqlite 
+
+    database interface and driver for sqlite (unsupported)
+
+=item  with-standalone
+
+    libraries needed to support the standalone simple pure perl server
+
+=item with-fastcgi-server
+
+    libraries needed to support the external fastcgi server
+ 
+=item with-fastcgi 
+
+    libraries needed to support the fastcgi handler
+
+=item with-speedycgi
+
+    libraries needed to support the speedycgi handler
+
+=item with-modperl1
+
+    libraries needed to support the modperl 1 handler
+
+=item with-modperl2
+
+    libraries needed to support the modperl 2 handler
+
+=item with-dev
+
+    tools needed for RT development
+
+=back
+
+=back
 
-1;
diff --git a/sbin/rt-validator.in b/sbin/rt-validator.in
index 42b9296..9cfcb47 100644
--- a/sbin/rt-validator.in
+++ b/sbin/rt-validator.in
@@ -82,35 +82,17 @@ GetOptions(
     'resolve',
     'force',
     'verbose|v',
+    'help|h',
 );
 
-usage() unless $opt{'check'};
-usage_warning() if $opt{'resolve'} && !$opt{'force'};
-
-sub usage {
-    print STDERR <<END;
-Usage: $0 options
-
-Options:
-
-    $0 --check
-    $0 --check --verbose
-    $0 --check --verbose --resolve
-    $0 --check --verbose --resolve --force
-
---check   - is mandatory argument, you can use -c, as well.
---verbose - print additional info to STDOUT
---resolve - enable resolver that can delete or create some records
---force   - resolve without asking questions
-
-Description:
+if ( $opt{help} || !$opt{check} ) {
+    require Pod::Usage;
+    print Pod::Usage::pod2usage( { verbose => 2 } );
+    exit;
+}
 
-This script checks integrity of records in RT's DB. May delete some invalid
-records or ressurect accidentally deleted.
+usage_warning() if $opt{'resolve'} && !$opt{'force'};
 
-END
-    exit 1;
-}
 
 sub usage_warning {
     print <<END;
@@ -1116,3 +1098,47 @@ sub prompt_integer {
 } }
 
 1;
+
+__END__
+
+=head1 NAME
+
+rt-validator - show the content of an attribute 
+
+=head1 SYNOPSIS
+
+    rt-validator --check 
+    rt-validator --check --verbose
+    rt-validator --check --verbose --resolve
+    rt-validator --check --verbose --resolve --force
+
+=head1 DESCRIPTION
+
+This script checks integrity of records in RT's DB. May delete some invalid
+records or ressurect accidentally deleted.
+
+=head1 OPTIONS
+
+=over
+
+=item check
+
+    mandatory.
+    
+    it's equall to -c
+
+=item verbose
+
+    print additional info to STDOUT
+    it's equall to -v
+
+=item resolve
+
+    enable resolver that can delete or create some records
+
+=item force
+
+    resolve without asking questions
+
+=back
+

-----------------------------------------------------------------------


More information about the Rt-commit mailing list