[Rt-commit] r19541 - in rt/3.999/trunk: .
sunnavy at bestpractical.com
sunnavy at bestpractical.com
Thu May 7 03:27:59 EDT 2009
Author: sunnavy
Date: Thu May 7 03:27:59 2009
New Revision: 19541
Modified:
rt/3.999/trunk/ (props changed)
rt/3.999/trunk/sbin/rt-update-config
Log:
r20882 at sunnavys-mb (orig r19329): sunnavy | 2009-04-23 09:17:02 +0800
add doc support
Modified: rt/3.999/trunk/sbin/rt-update-config
==============================================================================
--- rt/3.999/trunk/sbin/rt-update-config (original)
+++ rt/3.999/trunk/sbin/rt-update-config Thu May 7 03:27:59 2009
@@ -58,7 +58,7 @@
my %args;
die "unknown option"
- unless GetOptions( \%args, 'all', 'section=s', 'name=s', 'value=s', 'show',
+ unless GetOptions( \%args, 'name=s', 'value=s', 'show',
'without-doc', 'help', );
# XXX currently, $args{value} only supports string values.
@@ -69,7 +69,36 @@
}
else {
use Data::Dumper;
+ my %doc;
+ if ( ! $args{'without-doc'} ) {
+ eval {
+ require require Pod::POM;
+ };
+ if ( $@ ) {
+ warn "doc needs Pod::POM installed";
+ }
+ else {
+ my $parser = Pod::POM->new;
+ my $pom =
+ $parser->parse_file( $RT::BASE_PATH . '/lib/RT/Config.pm' )
+ or die $parser->error;
+ my $view = 'Pod::POM::View::Text';
+ require Pod::POM::View::Text;
+ for my $section ( $pom->head1 ) {
+ my $over = $section->over->[0];
+ for my $item ( $over->item ) {
+ my $title = $item->title;
+ my @items = split /\s*,\s*/, $title;
+ @items = map { s/C<(\w+)>/$1/; $_ } @items;
+ for ( @items ) {
+ $doc{$_} = $item->content->present($view);
+ $doc{$_} =~ s/^/## /mg;
+ }
+ }
+ }
+ }
+ }
my %map;
if ( $args{name} ) {
@@ -95,13 +124,15 @@
}
}
else {
- #XXX TODO add comments in $to_be_edited
- my $to_be_edited;
+ my $to_be_edited = '';
for my $name ( sort keys %map ) {
+ $to_be_edited .= $doc{$name} || '';
my $value = Data::Dumper->Dump( [ $map{$name} ], [''] );
$value =~ s/^\$ = //;
$value =~ s/;\s*$//;
$to_be_edited .= "set( $name => $value );\n";
+ $to_be_edited .= "\n"
+ if $doc{$name}; # add an extra blank line to ease eyes
}
my $update = edit($to_be_edited);
eval $update;
@@ -122,3 +153,4 @@
sub set {
RT->config->set(@_);
}
+
More information about the Rt-commit
mailing list