Alter the default wrap width for LDIF to expand to the terminal size,

with an optional rc file override.

FossilOrigin-Name: 8952098367b39f5ed484688b1ee9268663ad9c1e86c719accb44af4a56351498
This commit is contained in:
mahlon@laika.com 2013-03-15 17:02:18 +00:00
parent 52b46a6b2d
commit 96142cab5f

View file

@ -564,17 +564,28 @@ sub ldif
my $self = shift; my $self = shift;
my $use_temp = shift; my $use_temp = shift;
# find the terminal width
#
my $wrap = $conf->{'wrap'};
eval {
my $rows;
my $term = Term::ReadLine->new( 1 );
( $rows, $wrap ) = $term->get_screen_size() unless $wrap;
};
$wrap ||= 78;
# create tmpfile and link ldif object with it # create tmpfile and link ldif object with it
#
if ( $use_temp ) { if ( $use_temp ) {
my ( undef, $fname ) = my ( undef, $fname ) =
File::Temp::tempfile( 'shelldap_XXXXXXXX', DIR => '/tmp', UNLINK => 1 ); File::Temp::tempfile( 'shelldap_XXXXXXXX', DIR => '/tmp', UNLINK => 1 );
$self->{'ldif'} = Net::LDAP::LDIF->new( $fname, 'w', sort => 1 ); $self->{'ldif'} = Net::LDAP::LDIF->new( $fname, 'w', sort => 1, wrap => $wrap );
$self->{'ldif_fname'} = $fname; $self->{'ldif_fname'} = $fname;
} }
# ldif -> stdout # ldif -> stdout
else { else {
$self->{'ldif'} = Net::LDAP::LDIF->new( \*STDOUT, 'w', sort => 1 ); $self->{'ldif'} = Net::LDAP::LDIF->new( \*STDOUT, 'w', sort => 1, wrap => $wrap );
} }
return $self->{'ldif'}; return $self->{'ldif'};