#!/usr/bin/perl use strict; use warnings; use LATMOS::Accounts; use Getopt::Long; use Pod::Usage; =head1 NAME la-config - Tools to query configuration of LATMOS::Accounts system. =head1 SYNOPSIS List setup base, synchronisation la-config [option] =cut GetOptions( 'c|config=s' => \my $config, 'ls' => \my $listsynchros, 'base=s' => \my $base, 'help' => sub { pod2usage(0) }, ) or pod2usage(); =head1 OPTIONS =over 4 =item -c|--config configdir Use this configuration directory instead of the default one. =item -b|--base basename Perform query on this base =item --ls List synchronisation setup in config =back =cut my $LA = LATMOS::Accounts->new($config, noacl => 1); if ($listsynchros) { my $default_sync = $LA->default_synchro_name || ''; print "Syncro:\n"; foreach ($LA->list_synchro) { printf(" %s %s (%s => %s)\n", ($_ eq $default_sync ? '*' : ' '), $_, $LA->val("sync:$_", 'from', 'Err: No from'), join(', ', $LA->val("sync:$_", 'to', 'Err: No to')), ); } } else { my $default = $LA->default_base_name || ''; print "Bases:\n"; foreach ($LA->list_bases) { printf(" %s %s (%s)\n", ($_ eq $default ? '*' : ' '), $_, $LA->val($_, 'type', 'Err: no type') ); } }