Allow default attributes to be set via config and cmdline
authorDavor Ocelic <docelic@crystallabs.io>
Sun, 28 Apr 2019 21:40:06 +0200
changeset 101 cb4de2ecc7ab
parent 100 5975875d67b8
child 102 e92cb378144d
Allow default attributes to be set via config and cmdline This commit changes the default attribute list from a fixed '*' to a configurable list, defaulting to ['*']. It allows one to use config file or command line to set default attributes to retrieve and display - i.e. to set default attributes to '+' or to a list of multiple specific attributes. Printing or changing this value through env/setenv is currently not supported because env/setenv only work properly with string values while attributes is a list.
shelldap
--- a/shelldap	Mon Apr 15 14:18:12 2019 -0700
+++ b/shelldap	Sun Apr 28 21:40:06 2019 +0200
@@ -1437,7 +1437,7 @@
 {
 	my $self  = shift;
 	my $dn    = shift;
-	my @attrs = (@_) ? @_ : ('*');
+	my @attrs = (@_) ? @_ : @{$conf->{'attributes'}};
 
 	$self->display( $dn, \@attrs, 0 );
 }
@@ -2381,6 +2381,7 @@
 	'binddn|D=s',
 	'basedn|b=s',
 	'cacheage=i',
+	'attributes=s@',
 	'paginate=i',
 	'promptpass|W',
 	'timeout=i',
@@ -2413,8 +2414,9 @@
 
 # defaults
 $conf->{'configfile'} ||= "$ENV{'HOME'}/.shelldap.rc";
-$conf->{'cacheage'} ||= 300;
-$conf->{'timeout'}  ||= 10;
+$conf->{'cacheage'}   ||= 300;
+$conf->{'timeout'}    ||= 10;
+$conf->{'attributes'} ||= ['*'];
 
 # create and enter shell loop
 my $shell = LDAP::Shell->new();