diff options
author | Jonas Smedegaard <dr@jones.dk> | 2010-09-16 13:31:42 +0200 |
---|---|---|
committer | Jonas Smedegaard <dr@jones.dk> | 2010-09-16 13:31:42 +0200 |
commit | 8181988dd6e2e1ca34f66bbf16d13db5a3cbc934 (patch) | |
tree | 186e5951ffbf4f193baa9367acfaac65a1bfdfc7 /localuserinfo | |
parent | 0de67b8e1104879d5a27a6d289832824da2b3b80 (diff) |
Support all extracted infochunks and display most by default.
Diffstat (limited to 'localuserinfo')
-rwxr-xr-x | localuserinfo | 57 |
1 files changed, 47 insertions, 10 deletions
diff --git a/localuserinfo b/localuserinfo index bf0fe83..3a4e63a 100755 --- a/localuserinfo +++ b/localuserinfo @@ -20,7 +20,7 @@ my $ID = q$Id: localuserinfo,v 1.7 2007-02-07 15:08:09 jonas Exp $; # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA # -# TODO: Options to print other info than fullname +# TODO: Options to suppress infochunks # use strict; @@ -31,7 +31,13 @@ use User::grent; our $verbose = 1; # should we be verbose? my $ignore_badname = 0; # should we ignore bad names? +my $include_username = 1; my $include_fullname = 1; +my $include_office = 1; +my $include_workphone = 1; +my $include_homephone = 1; +my $include_other = 0; +my $include_addresshints = 1; my $include_mail = 0; our $custom_template; @@ -49,7 +55,13 @@ our $maildomain = &get_maildomain; unless ( GetOptions ( "quiet|q" => sub { $verbose = 0 }, + "username" => \$include_username, "fullname|n" => \$include_fullname, + "office" => \$include_office, + "workphone" => \$include_workphone, + "homephone" => \$include_homephone, + "other" => \$include_other, + "addresshints" => \$include_addresshints, "mail|m" => \$include_mail, "custom=s" => \$custom_template, "ignore-badname" => \$ignore_badname, @@ -68,7 +80,13 @@ while (defined(my $arg = shift(@ARGV))) { # TODO: Support custom ordering and custom delimiter my @infochunks; +push (@infochunks, 'username') if ($include_username); push (@infochunks, 'fullname') if ($include_fullname); +push (@infochunks, 'office') if ($include_office); +push (@infochunks, 'workphone') if ($include_workphone); +push (@infochunks, 'homephone') if ($include_homephone); +push (@infochunks, 'other') if ($include_other); +push (@infochunks, 'addresshints') if ($include_addresshints); push (@infochunks, 'mailaddress') if ($include_mail); my $template = $custom_template ? $custom_template : '%' . join('% %', @infochunks) . '%'; @@ -77,12 +95,17 @@ while (my $username = shift @names) { my $string; - my ($fullname, @addresses) = &getuserinfo($username); + my ($fullname, $office, $workphone, $homephone, $other, @addresshints) = &getuserinfo($username); my $mailaddress = "$username\@$maildomain"; $string = $template; $string =~ s/\%username\%/$username/g; $string =~ s/\%fullname\%/$fullname/g; + $string =~ s/\%office\%/$office/g; + $string =~ s/\%workphone\%/$workphone/g; + $string =~ s/\%homephone\%/$homephone/g; + $string =~ s/\%other\%/$other/g; + $string =~ s/\%addresshints\%/@addresshints/g; $string =~ s/\%mailaddress\%/$mailaddress/g; print "$string\n"; @@ -97,9 +120,11 @@ sub getuserinfo($) { my @addresshints; if (defined($other)) { @addresshints = grep {/^([\.[:alnum:]_-]+|\+)?@([\.[:alnum:]_-]+)?$/} split /\s+/, $other; + } else { + $other = ""; } - return ($fullname, @addresshints); + return ($fullname, $office, $workphone, $homephone, $other, @addresshints); } sub get_maildomain { @@ -144,15 +169,27 @@ general options: --quiet | -q don't give process information to stdout --ignore-badname ignore non-existing usernames instead of failing --help | -h usage message - --fullname | -n include fullname (enabled by default) - --mail | -m include email address + --username include username + --fullname | -n include fullname + --office include office + --workphone include work phone + --homephone include home phone + --other include full "other" field + --addresshints include address hints: words in "other" field + containing "@" + --mail | -m include email address: USERNAME\@MAILDOMAIN --custom=TEMPLATE custom template, e.g. '%username% (%fullname%)' available infochunks: - username - fullname - mailaddress - (default is '%fullname%' or space-delimited list - of enabled infochunks) + * username + * fullname + * office + * workphone + * homephone + other + * addresshints + * mailaddress + (all marked infosnippets are included by default, + in the order listed) --version | -v version number and copyright EOF } |